Back to Shark UI

Download Trigger

docs/utilities/download-trigger

latest6.0 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Download Trigger

Copy Markdown

Trigger file downloads programmatically.

DocsAPI

PreviewCode

Hello, World! This is a sample text file.

Download

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/download-trigger

Usage#

import { DownloadTrigger } from "@/registry/react/components/download-trigger";
<DownloadTrigger
  data="..."
  fileName="schema.json"
  mimeType="application/json"
>
  Download
</DownloadTrigger>

Examples#

Download SVG#

Download an SVG file by passing the SVG markup to data and setting mimeType to image/svg+xml.

PreviewCode

Download SVG

Promise#

Trigger downloads from a promise that returns a Blob, File, or string. Pass a function to data.

PreviewCode

Download

API Reference#

DownloadTrigger#

PropTypeDefault
data`DownloadableData(() => MaybePromise<DownloadableData>)`
fileNamestring-
mimeTypeFileMimeType-
asChildboolean-

For a complete list of props, see the Ark UI documentation.

[

Previous page

Client Only ](/docs/utilities/client-only)[

Next page

Format ](/docs/utilities/format)

On This Page

InstallationUsageExamplesDownload SVGPromiseAPI ReferenceDownloadTrigger