Skip to content

Theming

Every visual option of Vega Player is an attribute, so you theme it in the markup itself: no stylesheet, no class names, no build step. Each player on a page can look different.

<vega-player
src="/video.mp4"
poster="/poster.jpg"
color-primary="#ffffff"
color-controls="rgba(10, 10, 10, 0.85)"
play-btn-color="#ffffff"
play-btn-size="lg">
</vega-player>
color-primary="#8f8f8f" play-btn-color="#d4d4d4" play-btn-size="lg"
AttributeDefaultWhat it colors
color-primary#aaaProgress bar, volume fill, active menu items, hover states, spinner, retry button and, unless set below, the call-to-action button.
color-controlsrgba(0,0,0,0.7)Control bar and menus.
color-overlayrgba(0,0,0,0.95)Background behind the call-to-action modal.
play-btn-colorrgba(255,255,255,0.9)Background of the large centre play button.
cta-bg-colorcolor-primaryCall-to-action button.
cta-text-color#000Call-to-action text.
cta-hover-bg-color#fffCall-to-action button on hover.
cta-hover-text-color#000Call-to-action text on hover.
modal-description-colorrgba(255,255,255,0.7)Description text in the modal.

Any CSS color works: #hex, rgb(), hsl(), named colors…

<vega-player
src="/video.mp4"
play-btn-size="sm"
play-btn-color="#0a0a0a"
play-btn-icon="/icons/play.svg">
</vega-player>
AttributeValues
play-btn-sizesm, md (default) or lg.
play-btn-colorBackground color of the button.
play-btn-iconAn image URL, or inline SVG / icon-font markup (sanitised).
hide-play-buttonHides the centre button (the play button in the control bar stays).
<vega-player
src="/video.mp4"
aspect-ratio="21:9"
controls-visible
show-stop-button
hide-fullscreen-button>
</vega-player>
AttributeWhat it does
aspect-ratioBox shape, for example 16:9 (default), 4:3, 1:1, 21:9.
controls-visibleControls always on screen; controls-visible="false" removes them (background videos).
controls-hide-on-hoverHides the controls while the mouse is over the player.
hide-on-play-delaySeconds after which the controls fade out while playing.
show-stop-button, hide-fullscreen-buttonAdd or remove buttons.
show-playback-rate, enable-pip, enable-chromecastSpeed menu, Picture-in-Picture and Chromecast buttons.

The full list is in Attributes.

The attributes are live: change one and the player updates at once. Every attribute is also a property.

const player = document.querySelector('vega-player');
player.setAttribute('color-primary', '#ffffff');
player.playBtnSize = 'lg';

The player lives in a Shadow DOM, so page styles don’t leak in, and its interface uses the system font. Icon fonts used in play-btn-icon must be declared globally with @font-face. To change the font of the time display or the preview, use the optional ::part(time) and ::part(preview) hooks.