shadcn.io is not affiliated with official shadcn/ui
Framework
UI library
Installation
Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Usage
import { DownloadIcon, FileTextIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { DownloadTrigger } from "@/components/ui/download-trigger";
import { Item, ItemTitle } from "@/components/ui/item";const DownloadTriggerDemo = () => (
<div className="flex flex-col gap-4">
<Item variant="outline">
<FileTextIcon />
<ItemTitle>{content}</ItemTitle>
</Item>
<DownloadTrigger
asChild
data={content}
fileName="hello.txt"
mimeType="text/plain"
>
<Button size="lg" variant="outline">
<DownloadIcon />
Download
</Button>
</DownloadTrigger>
</div>
);
const content = "Hello, World! This is a sample text file.";Accessibility
KeyAction
- Enter
- Activate the focused control.
- Space
- Activate the focused control.
Demos
Download Svg
Promise
API Reference
DownloadTrigger
<button> data-slot="download-trigger"
PropType
dataDownloadData
What to download: a Blob or a string, a promise of one, or a function
that returns either.
fileNamestring
The name the file saves under, such as notes.txt.
mimeType?string
The file's type when data is a string, such as application/json.
- Default
"text/plain"
asChild?boolean
Renders your child element as the trigger, with this part's behavior.