Video
Videos are used to embed and play video content with custom controls and captions.
-
Pro Components -
Native Styles -
CSS + Layout Utilities -
Ever-Growing Pattern Library -
Unlimited Hosted Projects -
Pre-Built Pro Themes -
Pro Theme Builder -
Pro Color Tools -
Official Figma Design Kit -
WA Pro Perpetual License -
Actual Human™ Support
Already have Pro? Log in
Examples
Adding Video Sources
The simplest way to add a video is with the src attribute.
For multiple formats or additional options, use <source> elements instead.
<wa-video title="Creating a Font Awesome Kit" poster="/assets/images/fa-part-1.jpg"> <source src="https://uploads.webawesome.com/01-create-your-first-kit.mp4" type="video/mp4" /> <source src="https://uploads.webawesome.com/01-create-your-first-kit.ogv" type="video/ogg" /> <source src="https://uploads.webawesome.com/01-create-your-first-kit.webm" type="video/webm" /> </wa-video>
Controls
Use the controls attribute to choose which playback controls appear. Switch presets below to compare them.
| Preset | Shows |
|---|---|
standard |
Playback, a seekable timeline, elapsed and total time, volume, captions, and fullscreen |
full |
Everything in standard, plus playback speed and picture-in-picture |
none |
No controls — the video still plays programmatically, and the poster overlay and captions stay visible |
Poster Image
Add a poster image that displays before the video plays. If no poster is provided, no overlay is shown and the browser will display the first frame of the video instead.
Captions & Subtitles
Add a <track> element to enable captions using standard WebVTT files.
Captions are rendered above the video controls and automatically adjust position when controls show or hide.
Icon Slots
Every control's icon has a slot — poster-icon, play-icon, pause-icon, volume-icon, mute-icon, fullscreen-icon, and exit-fullscreen-icon — so you can supply your own. This example swaps the poster, play, and pause icons.
Playlists
Group a series of related videos into <wa-video-playlist> to play them in sequence with built-in navigation.
Video Recommendations
Recommended to ensure fast loading, broad browser compatibility, and the best playback experience across devices.
Video Encoding
| Setting | Recommended | Reason |
|---|---|---|
| Codec | H.264 (MP4) | Broadest browser and device support |
| Resolution | 1280×720 (720p) | Good balance of quality and file size |
| Frame rate | 24–30fps | Smooth motion without excess data |
| Bitrate | 2–5 megabits/s | Good quality at 720p without buffering |
Poster Images
| Setting | Recommended | Reason |
|---|---|---|
| Format | JPEG (80–85%) or WebP | Small file size with wide browser support |
| File size | Under 200KB | Fast initial load before video starts |
| Aspect ratio | 16:9 | Matches standard video dimensions |
| Resolution | Match video exactly | Prevents layout shift on load |
Caption Files
| Setting | Recommended | Reason |
|---|---|---|
| Format | WebVTT (.vtt) | Only format supported by the HTML <track> element |
| Encoding | UTF-8 | Ensures special characters and non-Latin scripts render correctly |
| Timing | Frame accurate | Prevents captions from appearing early or late |
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://ka-f.webawesome.com/[email protected]/components/video/video.js';
After installing Web Awesome via npm, import this component:
import '@awesome.me/webawesome/dist/components/video/video.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/video/video.js';
To import this component for React 18 or below, use the following code:
import WaVideo from '@awesome.me/webawesome/dist/react/video/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | The default slot. Place <source> and <track> elements for a single video. Alternatively, use the src attribute for a single source. |
controls-after-play
|
Content inserted immediately after the play/pause button. Used by <wa-video-playlist> to inject the next button. |
controls-start
|
Content inserted at the start of the controls bar (before play/pause). Used by <wa-video-playlist> to inject the prev button. |
exit-fullscreen-icon
|
Icon shown on the fullscreen button when in fullscreen. |
fullscreen-icon
|
Icon shown on the fullscreen button when not in fullscreen. |
mute-icon
|
Icon shown on the volume/mute button when muted or volume is 0. |
pause-icon
|
Icon shown on the play/pause button when playing. |
play-icon
|
Icon shown on the play/pause button when paused. |
poster-icon
|
Icon shown on the poster play button. Defaults to a play-circle icon. |
volume-icon
|
Icon shown on the volume/mute button when audio is active. |
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects |
|---|---|---|
autoplayautoplay |
Enables autoplay when the component connects.
Type
boolean
Default
false
|
|
autoplayMutedautoplay-muted |
Enables autoplay in a muted state.
Type
boolean
Default
false
|
|
autoplayOnVisibleautoplay-on-visible |
Automatically resumes playback when the player scrolls back into view after being paused by scrolling out.
Type
boolean
Default
false
|
|
controlscontrols |
The video's controls preset.
-
none — no controls are shown.
- standard — shows the timeline, play/pause, volume, captions, and fullscreen.
- full — all of the above plus playback speed and picture-in-picture.
Type
'none' | 'standard' | 'full'
Default
'standard'
|
|
currentTimecurrentTime |
The current playback position in seconds.
Type
number
Default
0
|
|
durationduration |
The total duration of the video in seconds.
Type
number
Default
0
|
|
iconLibraryicon-library |
Icon library used for all built-in control icons. Defaults to 'system'.
Type
string
Default
'system'
|
|
looploop |
Loops the video when playback ends.
Type
boolean
Default
false
|
|
mutedmuted |
When set, the video will be muted.
Type
boolean
Default
false
|
|
playingplaying |
Indicates whether the video is currently playing.
Type
boolean
Default
false
|
|
posterposter |
Poster image URL
Type
string
Default
''
|
|
preloadpreload |
Controls how the browser preloads the video. Defaults to 'metadata' to minimize data usage.
Type
'auto' | 'metadata' | 'none'
Default
'metadata'
|
|
srcsrc |
The URL of the video source. For multiple formats, use
<source> elements instead.
Type
string
Default
''
|
|
thumbnailsthumbnails |
A URL pointing to a WebVTT file for timeline thumbnail previews.
Type
string
Default
''
|
|
titletitle |
The video's title.
Type
string
Default
''
|
|
volumevolume |
The video's volume.
Type
number
Default
1
|
Methods
Learn more about methods.
| Name | Description | Arguments |
|---|---|---|
exitFullscreen() |
Exits fullscreen mode. | |
getState() |
Gets the current playback state. | |
getVideoElement() |
Gets the native video element. | |
pause() |
Pauses playback. | |
play() |
Starts playback. | |
requestFullscreen() |
Enters fullscreen mode. | |
seek() |
Seeks to a specific time in the video. |
time: number
|
setPlaybackRate() |
Sets the playback rate (speed). |
rate: number
|
setVolume() |
Sets the volume level. |
volume: number
|
toggleMute() |
Toggles the muted state. | |
togglePlay() |
Toggles between play and pause. |
Events
Learn more about events.
| Name | Description |
|---|---|
ended |
Emitted when playback ends. |
error |
Emitted when an error occurs while loading/playing. |
loadedmetadata |
Emitted when metadata has been loaded. |
pause |
Emitted when playback stops. |
play |
Emitted when playback begins. |
timeupdate |
Emitted when the time changes. |
volumechange |
Emitted when the volume changes. |
CSS Custom Properties
Learn more about CSS custom properties.
| Name | Description |
|---|---|
--controls-background |
The background of the controls bar and mobile controls.
Default
var(--wa-color-surface-default)
|
--controls-color |
The text and icon color used throughout the controls overlay, title overlay, and mobile controls.
Default
white
|
--poster-play-button-background |
The background of the play button shown over the poster image. Also used to derive the hover state via color-mix().
Default
var(--wa-color-surface-default)
|
CSS Parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
caption |
The caption text element. |
::part(caption)
|
caption-overlay |
The custom caption overlay container. |
::part(caption-overlay)
|
controls |
The controls container. |
::part(controls)
|
controls-overlay |
The overlay wrapping timeline and controls bar. |
::part(controls-overlay)
|
poster-overlay |
The poster image overlay. |
::part(poster-overlay)
|
poster-play-button |
The play button on the poster overlay. |
::part(poster-play-button)
|
thumbnail |
The thumbnail preview. |
::part(thumbnail)
|
timeline |
The timeline/scrubber container. |
::part(timeline)
|
timeline-indicator |
The timeline slider's filled indicator (forwarded from wa-slider). |
::part(timeline-indicator)
|
timeline-thumb |
The timeline slider's thumb (forwarded from wa-slider). |
::part(timeline-thumb)
|
timeline-track |
The timeline slider's track (forwarded from wa-slider). |
::part(timeline-track)
|
video |
The video element. |
::part(video)
|
video-title-overlay |
The title text overlay. |
::part(video-title-overlay)
|
video-wrapper |
The component's outer wrapper. |
::part(video-wrapper)
|
base |
Deprecated. Use the video-wrapper part instead. |
::part(base)
|
Dependencies
This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.
<wa-button><wa-dropdown><wa-dropdown-item><wa-icon><wa-popover><wa-popup><wa-slider><wa-spinner><wa-tooltip>