Image

Display image message parts with preview, loading states, and fullscreen dialog.

Outline (click to zoom)
landscape-sm.jpg
landscape-default.jpg
Muted
landscape-sm.jpg
landscape-default.jpg

Getting Started

Add image

npx shadcn@latest add https://r.assistant-ui.com/image.json

Use in your application

Pass Image to MessagePrimitive.Parts:

/components/assistant-ui/thread.tsx
import { Image } from "@/components/assistant-ui/image";

const AssistantMessage: FC = () => {
  return (
    <MessagePrimitive.Root className="...">
      <MessagePrimitive.Parts
        components={{
          Image,
        }}
      />
    </MessagePrimitive.Root>
  );
};

Variants

Use the variant prop to change the visual style.

<Image.Root variant="outline" /> // Border (default)
<Image.Root variant="ghost" />   // No border
<Image.Root variant="muted" />   // Background fill

Sizes

Use the size prop to control the maximum width.

<Image.Root size="sm" />      // max-w-64 (256px)
<Image.Root size="default" /> // max-w-96 (384px)
<Image.Root size="lg" />      // max-w-[512px]
<Image.Root size="full" />    // w-full

API Reference

Composable API

The component exports composable sub-components:

import {
  Image,
  ImageRoot,
  ImagePreview,
  ImageFilename,
  ImageZoom,
} from "@/components/assistant-ui/image";

<ImageRoot variant="muted" size="lg">
  <ImageZoom src="https://example.com/photo.jpg" alt="Photo">
    <ImagePreview src="https://example.com/photo.jpg" alt="Photo" />
  </ImageZoom>
  <ImageFilename>photo.jpg</ImageFilename>
</ImageRoot>
ComponentDescription
ImageDefault export, renders complete image part
Image.RootContainer with variant and size styling
Image.PreviewImage container with loading/error states
Image.FilenameOptional filename display below image
Image.ZoomMedium-style zoom overlay (click to expand, ESC to close)
  • Attachment - File attachments in composer and messages
  • File - Non-image file message parts