Download Trigger
Trigger file downloads programmatically.
Motivation
The DownloadTrigger component provides a convenient way to programmatically trigger file downloads in web
applications. It handles the complexities of downloading files, whether they are URLs, Blobs, or other data types.
Examples
Basic
Pass the data you want to download to the data prop, and specify the fileName and mimeType of the file.
Download SVG
Here's an example of how to download an SVG file.
Promise
You can also trigger downloads from a promise that returns a Blob, File, or string.
API Reference
DownloadTrigger
| Prop | Default | Type |
|---|---|---|
data | DownloadableData | (() => MaybePromise<DownloadableData>)The data to download | |
fileName | stringThe name of the file to download | |
mimeType | FileMimeTypeThe MIME type of the data to download | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |