Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Download Trigger for React and Tailwind

Trigger file downloads programmatically.

Hello, World! This is a sample text file.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/download-trigger.json

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.

Promise

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

API Reference

DownloadTrigger

PropTypeDefault
dataDownloadableData | (() => MaybePromise<DownloadableData>)-
fileNamestring-
mimeTypeFileMimeType-
asChildboolean-

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