Figure-level media frame: fixed aspect ratio reserves space, src renders through Image's fallback chain, children accept arbitrary media, and caption/credit come from Figure.
Design intent
Media is the figure-level primitive for article and card imagery: it reserves aspect-ratio space so layouts never shift, renders src through Image's fallback chain, accepts arbitrary media as children, and pairs caption and credit via Figure.
npx @slipstream-ui/cli@latest add mediaProps
| Prop | Type | Default | Description |
|---|---|---|---|
| aspect | 'video' | 'square' | 'wide' | string | 'video' | Aspect ratio preset or any CSS aspect-ratio value. |
| src | string | — | Image URL rendered through Image's fallback chain. |
| alt | string | '' | Alt text for src media. |
| sizes | string | — | Responsive sizes hint forwarded to the image. |
| priority | boolean | false | Load eagerly for the LCP image. |
| fallback | ReactNode | — | Content when src is absent or fails; also used with no children. |
| caption | ReactNode | — | Caption in figcaption below the frame. |
| credit | ReactNode | — | Source/attribution line under the caption. |
| align | 'left' | 'center' | 'left' | Caption alignment. |
| className | string | — | Additional CSS classes to apply. |
Anti-patterns
validate_usage is the MCP tool that rejects these mistakes: the same list agents see over MCP and in the canonical markdown.
Don't use Media for generated placeholder art
CoverImage adds the seeded token-gradient fallback for imageless entities; Media is for real media with captions.
tsx// Prefer for entity covers<CoverImage seed={slug} mark={<Icon />} />// Prefer Media for captioned article imagery
Accessibility
- figure/figcaption associates the caption with the media programmatically.
- The aspect-ratio box prevents layout shift while media loads.
- Provide alt for src images; embedded media needs its own title or label.
Content guidelines
Captions and credits
- Caption describes the media; credit names the source
- Keep captions to one sentence
- Alt text describes the image for screen readers separately
Good examples
- caption: Final round, credit: USDSC 2026
Bad examples
- caption: image, credit: web
Composition
Compose with Image: src media renders through Image for the src -> fallbackSrc -> fallback chain
<Media src="/a.jpg" alt="A" sizes="100vw"/>
Compose with Figure: Media is a Figure with an aspect-ratio frame; Figure alone has no frame
<Media aspect="square" caption="Square"><Chart/></Media>
Related components: Figure, CoverImage, Image
Dependencies
What the registry installs alongside this component. Package imports already include these.
npm packages
- class-variance-authority
- clsx
- tailwind-merge
Browser support
| Browser | Tested versions |
|---|---|
| Chrome | 111+ (Mar 2023) |
| Edge | 111+ (Mar 2023) |
| Firefox | 121+ (Dec 2023) |
| Safari | 17.2+: macOS & iOS (Dec 2023) |
Slipstream components rely only on CSS custom properties, Flexbox/Grid, and ARIA, the everyday baseline of the last two years of evergreen releases. Anything newer is progressive enhancement: unsupported browsers keep full functionality with static behavior instead of animations.