# Attachment: Broken image

> When an image preview fails to load, it falls back to a file icon.

Example: https://hextaui.com/docs/attachment/examples/broken-image
Component docs: https://hextaui.com/docs/attachment.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/attachment-broken-image.json
```

This adds `components/examples/attachment/broken-image.tsx` with the Attachment component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/attachment/broken-image.tsx"
import {
  Attachment,
  AttachmentContent,
  AttachmentDescription,
  AttachmentMedia,
  AttachmentTitle,
} from "@/components/ui/attachment"

export function AttachmentBrokenImage() {
  return (
    <Attachment>
      <AttachmentMedia variant="image">
        <img src="/preview/missing.png" alt="" />
      </AttachmentMedia>
      <AttachmentContent>
        <AttachmentTitle>missing.png</AttachmentTitle>
        <AttachmentDescription>Preview unavailable</AttachmentDescription>
      </AttachmentContent>
    </Attachment>
  )
}
```

## Props in this example

### AttachmentMedia

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"icon" \| "image"` | `"icon"` | image wraps its child in a square AspectRatio with a file icon fallback. |

## More Attachment examples

- [Image](https://hextaui.com/docs/attachment/examples/image.md)
- [States](https://hextaui.com/docs/attachment/examples/states.md)
- [Upload flow](https://hextaui.com/docs/attachment/examples/upload-flow.md)
- [Sizes](https://hextaui.com/docs/attachment/examples/sizes.md)
- [Long names](https://hextaui.com/docs/attachment/examples/long-names.md)
- [Group](https://hextaui.com/docs/attachment/examples/group.md)
- [Trigger](https://hextaui.com/docs/attachment/examples/trigger.md)
- [Composer](https://hextaui.com/docs/attachment/examples/composer.md)
- [Stress](https://hextaui.com/docs/attachment/examples/stress.md)
- [Right to left](https://hextaui.com/docs/attachment/examples/rtl.md)
