Download Trigger

Trigger file downloads programmatically.

DownloadTrigger downloads a URL, Blob, string or the result of a promise when clicked.

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

Defines the <button> element.

AttributeDefaultType
data
DownloadableData | (() => MaybePromise<DownloadableData>)

The data to download

fileName
string

The name of the file to download

mimeType
FileMimeType

The MIME type of the data to download

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.