# Avatar Upload (/docs/components/avatar-upload)



<ComponentPreview name="avatar-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/avatar-upload
        ```
      </CodeBlockTab>

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

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

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

  <Tab value="Manual">
    Install [Upload](/docs/components/upload) first, then copy:

    <ComponentSource name="avatar-upload" />
  </Tab>
</Tabs>

## Usage [#usage]

```tsx
import { AvatarUpload } from "@/components/avatar-upload"
```

```tsx
<AvatarUpload
  src={user.image}
  onChange={(item) => updateUser({ image: item?.result?.url ?? null })}
/>
```

## Props [#props]

<TypeTable
  type="{
  adapter: {
    type: &#x22;UploadAdapter&#x22;,
    default: 's3Adapter({ endpoint: &#x22;/api/upload&#x22; })',
    description: &#x22;Where files go.&#x22;,
  },
  src: { type: &#x22;string | null&#x22;, description: &#x22;The current avatar URL.&#x22; },
  size: {
    type: &#x22;number&#x22;,
    default: &#x22;512&#x22;,
    description: &#x22;Output size in pixels (square, WebP).&#x22;,
  },
  onChange: {
    type: &#x22;(item | null) => void&#x22;,
    description: &#x22;Called after upload, or with null on removal.&#x22;,
  },
  name: { type: &#x22;string&#x22;, description: &#x22;Form field name.&#x22; },
}"
/>
