---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Media frame

A box for a photo, a map, a cover or an upload, at a fixed shape, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `MediaFrame`.

## Try it

Pick a look (each shape empty or holding media, a picture that fails to load, the frame in a card) or switch the shape (auto takes the media’s own height), turn loading on, hold the empty state with its icon and action, a block of media or a broken picture with its fallback (the icon or your own words), add a caption.

No picture is loaded: the example ships no image, so the media is a plain block of our own, and the broken picture’s source is an empty address that never loads.

## When to use

- A box for a photo, a map, a cover or an upload, at a fixed shape.
- Use it wherever a picture will stand (a cover, a product photo, a map, an upload), never Empty or an Avatar bent into a box. Give it a width; the ratio gives its height.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Media frame on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-media-frame.json --yes
```

```text
Add the Goop Media frame to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { MediaFrame, MediaFrameImage, MediaFrameMedia, MediaFrameEmpty } from '@/components/ui/goop/media-frame';
import { Button } from '@/components/ui/goop/button';

<>
  <MediaFrame ratio="square" className="w-60">
    <MediaFrameEmpty
      action={
        <Button variant="outline">
          Choose photo
        </Button>
      }
    >
      No cover art yet
    </MediaFrameEmpty>
  </MediaFrame>
  <MediaFrame ratio="16/9">
    <MediaFrameEmpty icon="map-2">The route map goes here</MediaFrameEmpty>
  </MediaFrame>
  <MediaFrame ratio="4/3" caption="The harbour from the north wall.">
    <MediaFrameImage src="/harbour.jpg" alt="Boats in a harbour at dawn" />
  </MediaFrame>
  <MediaFrame ratio="4/3">
    <MediaFrameImage src="/ridge.jpg" alt="The ridge path above the bay" fallback="The ridge path above the bay" />
  </MediaFrame>
</>
```

- Fits: list, record: row (media: some).
- Also known as: AspectRatio, ImagePlaceholder, Figure.
- height, width, padding, gap, corner, background, text: add no class for these.

## API reference

### Options

- `ratio?: 'square' | '4/3' | '16/9' | 'auto' = '16/9'` — The box's shape; `auto` the picture's own height.
- `loading?: boolean = false` — While true the box holds a skeleton and says it is busy; the picture fades in after.
- `caption?: ReactNode` — A line under the box saying what the picture shows; it names the figure.
- `children?: ReactNode` — The picture (`MediaFrameImage`, or your own element in `MediaFrameMedia`) or its empty state (`MediaFrameEmpty`).

### Parts

- `MediaFrameImage` — The picture; alt: string — What the picture shows, for a reader who cannot see it (`""` for a picture that says nothing); fit?: 'cover' | 'contain' = 'cover' — `cover` fills the box, cutting the rest; `contain` shows the whole picture; fallback?: ReactNode — What the box shows when the picture fails to load: by default the pack icon `photo-off` on the frame's fill
- `MediaFrameMedia` — Your own media element (a `picture`, a `video`, a map) as the frame's picture
- `MediaFrameEmpty` — What the box shows until there is a picture; icon?: IconName — The pack icon over the words (default `photo`; `map-2` for a map); action?: ReactNode — An action under the words: the theme's Button ("Choose photo"); children: ReactNode — One short line saying what goes here ("No photo yet")

- data-slot values (to select a part by): media-frame, media-frame-box, media-frame-caption, media-frame-empty, media-frame-empty-action, media-frame-empty-icon, media-frame-empty-words, media-frame-fallback, media-frame-fallback-icon, media-frame-image, media-frame-media, media-frame-skeleton

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Button](/themes/trail/components/button): A button with words that runs an action, in several looks and sizes.
- [Carousel](/themes/trail/components/carousel): A strip of pictures that scroll sideways, two in view, with previous and next buttons, for a gallery or a product's photos.
- [Meta facts](/themes/trail/components/meta-facts): A strip of a record's short facts, such as its status, owner and dates, each a label over its value.
- [Feature grid](/themes/trail/components/feature-grid): A grid of feature cells, each an icon, a title and a line, for a marketing or a pricing page that lists what a product does.
