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





`DownloadButton` requests a presigned GET URL and triggers a native browser download.

## Preview [#preview]

<DemoPreview name="download-button-demo.tsx">
  <DownloadButtonDemo />
</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 { DownloadButton } 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/download-button
        ```
      </CodeBlockTab>

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

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

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

***

## Usage [#usage]

```tsx
"use client";

import { useDownload } from "@dimah-s3/react";
import { DownloadButton } from "@dimah-s3/ui";

export function AvatarDownloader({ avatarKey }: { avatarKey: string }) {
  const download = useDownload({ route: "avatar" });

  return (
    <DownloadButton
      download={download}
      objectKey={avatarKey}
      variant="outline"
    />
  );
}
```

***

## Props [#props]

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

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

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

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

  <Accordion title="Can multiple list items share a single useDownload hook?">
    Yes. `useDownload` tracks `objectKey` internally so loading states and status toasts only affect the button matching the active key.
  </Accordion>

  <Accordion title="How do I show download progress instead of a spinner?">
    Use the [`ProgressDownloadButton`](https://dimah-s3.vercel.app/docs/react/ui/components/progress-download-button) component paired with `useDownload({ route, mode: "fetch" })`.
  </Accordion>
</Accordions>
