# Product Media (/docs/components/product-media-upload)



<ComponentPreview name="product-media-upload" />

## Installation [#installation]

<Tabs items="[&#x22;Command&#x22;, &#x22;Manual&#x22;]">
  <Tab value="Command">
    <CodeBlockTabs defaultValue="npm">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="npm">
          npm
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="pnpm">
          pnpm
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="yarn">
          yarn
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="bun">
          bun
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="npm">
        ```bash
        npx shadcn@latest add @uploadcn/product-media-upload
        ```
      </CodeBlockTab>

      <CodeBlockTab value="pnpm">
        ```bash
        pnpm dlx shadcn@latest add @uploadcn/product-media-upload
        ```
      </CodeBlockTab>

      <CodeBlockTab value="yarn">
        ```bash
        yarn dlx shadcn@latest add @uploadcn/product-media-upload
        ```
      </CodeBlockTab>

      <CodeBlockTab value="bun">
        ```bash
        bun x shadcn@latest add @uploadcn/product-media-upload
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Tab>

  <Tab value="Manual">
    Install [Upload](/docs/components/upload) and the shadcn `button` component, then copy:

    <ComponentSource name="product-media-upload" />
  </Tab>
</Tabs>

## Usage [#usage]

```tsx
import { ProductMediaUpload } from "@/components/product-media-upload"
```

```tsx
<ProductMediaUpload
  maxFiles={8}
  onChange={(images) => setImages(images.map((image) => image.result))}
/>
```

Every tile has keyboard-accessible buttons to make it the cover or move it, so reordering doesn't depend on drag and drop. Order is kept in the component and reported through `onChange`.

## Props [#props]

<TypeTable
  type="{
  adapter: {
    type: &#x22;UploadAdapter&#x22;,
    default: 's3Adapter({ endpoint: &#x22;/api/upload&#x22; })',
    description: &#x22;Where files go.&#x22;,
  },
  uploader: {
    type: &#x22;Uploader&#x22;,
    description: &#x22;An uploader from `useUploader`, instead of options.&#x22;,
  },
  maxFiles: { type: &#x22;number&#x22;, default: &#x22;8&#x22; },
  maxSize: { type: &#x22;number&#x22;, default: &#x22;20 MB&#x22; },
  onChange: {
    type: &#x22;(images) => void&#x22;,
    description: &#x22;Images in display order; the first is the cover.&#x22;,
  },
  className: { type: &#x22;string&#x22; },
}"
/>
