2.0 alpha
These docs describe 2.0. Install it with @once-ui-system/core@alpha.
On 1.8.x? Read the 1.x docs
TrademarkTrademarkDocs
Ctrl k
Search docs...
Components

Media

Updated: May 9, 2025
View on GitHub
Media handles responsive media content with support for lazy loading, aspect ratios, and intelligent rendering of videos or embeds. Use it for dynamic content blocks with consistent behavior. Show a skeleton block while content is loading. Only works when aspectRatio is specified. The caption prop renders a ReactNode below the image, making it easy to provide additional details. It will render the image as figure and the caption as figcaption. Enable full-screen zooming for images and videos.
The Media component will automatically detect the aspect ratio of the image and set it to auto if not specified. You can provide an explicit aspect ratio using the aspectRatio prop. Use the stretch prop to drop the intrinsic aspect ratio and let the media take whatever box it is in. (fill is the layout prop every component has — fillWidth and fillHeight together.) You can pass a number to sizes for a common responsive pattern. sizes={768} expands to (max-width: 768px) 100vw, 768px. The component auto-detects and renders YouTube links, just pass a YouTube URL to the src prop. For MP4 and other file-based video, set controls to render a minimal custom player with play/pause, seek, mute, and fullscreen. Keyboard shortcuts: space (play/pause), m (mute), f (fullscreen), arrow keys (seek).
Prop
Type
Default
aspectRatio
stringoriginal
height
number
alt
string
loading
booleanfalse
objectFit
CSSProperties["objectFit"]cover
enlarge
booleanfalse
srcrequired
string
unoptimized
booleanfalse
sizes
stringnumber
100vw
priority
boolean
caption
ReactNode
stretch
Drop the intrinsic aspect ratio and let the media fill its box.
booleanfalse
fillWidth
booleantrue
loop
booleantrue
autoplay
booleantrue
sound
booleanfalse
controls
booleanfalse
style
React.CSSProperties
className
string
…and every FlexProps propinherited
Edit this page on GitHub
TrademarkTrademark
Built with curiosity by Lorant One and the Design Engineers Club