# Media

Aspect-ratio media frame with image fallback chain and caption/credit

> Component ID: `media`
> Import: `import { Media } from '@slipstream-ui/core'`
> Docs: https://slipstreamui.com/docs/components/media
> Registry: https://slipstreamui.com/registry/media.json
> Tier: molecule · Package: @slipstream-ui/core@0.16.0
> Manifest schema: v1 · manifest: v1

## 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.

## Props

| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
| aspect | `'video' | 'square' | 'wide' | string` | `video` | no | Aspect ratio preset or any CSS aspect-ratio value; reserves layout space |
| src | `string` | — | no | Image URL rendered through Image's src -> fallback chain |
| alt | `string` | `` | no | Alt text for src media; required for meaningful images |
| sizes | `string` | — | no | Responsive sizes hint forwarded to the image |
| priority | `boolean` | `false` | no | Load eagerly at high priority for the LCP image |
| fallback | `ReactNode` | — | no | Content shown when src is absent or fails; also used when no children are provided |
| caption | `ReactNode` | — | no | Caption rendered in figcaption below the frame |
| credit | `ReactNode` | — | no | Optional source/attribution line under the caption |
| align | `'left' | 'center'` | `left` | no | Caption alignment |
| className | `string` | — | no | Additional CSS classes to apply |

## Examples

### Article hero image

Captioned hero with reserved 2:1 space

```tsx
<Media
  src="/photos/studio.jpg"
  alt="Dance studio floor"
  aspect="wide"
  caption="The practice floor at Studio West"
  credit="Photo: Jane Doe"
/>
```

### Embedded video

Arbitrary media inside the aspect frame

```tsx
<Media aspect="video" caption="Championship final">
  <iframe src="..." title="Final" className="h-full w-full" />
</Media>
```

## Anti-patterns

- **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.

## Accessibility

- **Caption association**: Renders figure/figcaption via Figure so captions are programmatically tied to the media
- **Layout stability**: Aspect-ratio box reserves space before the image loads, preventing CLS

## Composition

- Compose with **Image** — src media renders through Image for the src -> fallbackSrc -> fallback chain
  
  ```tsx
  <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
  
  ```tsx
  <Media aspect="square" caption="Square"><Chart/></Media>
  ```
- Related: Figure, CoverImage, Image

