Video
A video with native controls and captions.
A video with a poster
Video plays a video with the browser's controls. poster shows an image until it plays, captions adds a subtitles track, and fit sets how the video fills its box. autoplay always starts muted, because browsers only autoplay silent video.
Video(
.config(
w: fill
maxW: 480
aspect: 1.78
cornerRadius: 14
fit: cover
poster: '/og.png'
src: 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4'
)
)Config keys
| Key | Type | Default | Meaning |
|---|---|---|---|
src | src | Video URL. | |
poster | src | Poster image. | |
captions | src | WebVTT captions URL. | |
autoplay | bool | Autoplay (implies muted). | |
loop | bool | Loop. | |
muted | bool | Muted. | |
controls | bool | true | Show controls. |
fit | cover | contain | fill | contain | How the video fills its box. |
w (width) | len | fill | hug | Width: a length, fill (share the remaining space) or hug (fit content, default). | |
h (height) | len | fill | hug | Height: a length, fill or hug (default). | |
size (s) | size | Width and height together: size: 200 or size: (200, 120). | |
minW (minWidth) | len | Minimum width. | |
maxW (maxWidth) | len | Maximum width. | |
minH (minHeight) | len | Minimum height. | |
maxH (maxHeight) | len | Maximum height. | |
aspect (aspectRatio) | num | Aspect ratio (width / height), e.g. 16/9. | |
cornerRadius | radius | Corner radius. | |
margin | insets | Space outside the object: all(8), sym(x: 8, y: 4), only(top: 8). | |
opacity | num | Opacity from 0 to 1. | |
hide (hidden) | bool | Removes the object from layout and the accessibility tree. | |
shrink | num | 1 | Shrink priority when space runs out. Lower shrinks first; 0 never shrinks. |
flex | num | 1 | Share of remaining space for fill sizes. |
cursor | auto | pointer | text | grab | grabbing | move | notAllowed | crosshair | none | Pointer cursor. | |
className (class) | txt | Extra CSS class names: styling hooks for your own stylesheet (hover rules, third-party CSS). |
Events
.on(...) accepts tap, press, hover, hoverEnd, focus, blur, key, drag, swipe, mount, unmount, visible.