# Upload Button (https://dimah-s3.vercel.app/docs/react/ui/components/upload-button)





`UploadButton` connects directly to a `useUpload` hook and triggers the native OS file picker.

## Preview [#preview]

<DemoPreview name="upload-button-demo.tsx">
  <UploadButtonDemo />
</DemoPreview>

## Install [#install]

Complete [UI setup](https://dimah-s3.vercel.app/docs/react/ui) first — stylesheet and toaster. Then
add this component:

<Tabs items="[&#x22;npm package&#x22;, &#x22;shadcn registry&#x22;]">
  <Tab value="npm package">
    ```tsx
    import { UploadButton } from "@dimah-s3/ui";
    ```
  </Tab>

  <Tab value="shadcn registry">
    <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 @dimah-s3/upload-button
        ```
      </CodeBlockTab>

      <CodeBlockTab value="pnpm">
        ```bash
        pnpm dlx shadcn@latest add @dimah-s3/upload-button
        ```
      </CodeBlockTab>

      <CodeBlockTab value="yarn">
        ```bash
        yarn dlx shadcn@latest add @dimah-s3/upload-button
        ```
      </CodeBlockTab>

      <CodeBlockTab value="bun">
        ```bash
        bun x shadcn@latest add @dimah-s3/upload-button
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Tab>
</Tabs>

***

## Usage [#usage]

```tsx
"use client";

import { useUpload } from "@dimah-s3/react";
import { UploadButton } from "@dimah-s3/ui";

export function AvatarUploader() {
  const upload = useUpload({
    route: "avatar",
  });

  return <UploadButton upload={upload} label="Choose Avatar" />;
}
```

***

## Props [#props]

```ts
import type { UploadButtonProps } from "@dimah-s3/ui";
```

<AutoTypeTable path="packages/ui/src/components/dimah-s3/upload/upload-button.tsx" name="UploadButtonProps" />

## Frequently asked questions [#frequently-asked-questions]

<Accordions>
  <Accordion title="How do I dismiss the status row after upload?">
    Completed and failed attachments include a dismiss control that calls `upload.reset()`. You can also call `reset()` yourself.
  </Accordion>

  <Accordion title="How do I disable the inline attachment status list?">
    Pass `status={false}`:

    ```tsx
    <UploadButton upload={upload} status={false} />
    ```
  </Accordion>

  <Accordion title="How do I enable toast notifications on completion?">
    Pass `toast={true}` (make sure `<Toaster />` is mounted near your app root):

    ```tsx
    <UploadButton upload={upload} toast={true} />
    ```
  </Accordion>
</Accordions>
