Skip to Content
Documentation
Getting startedComponentsChartsTheming
Get Pro
Overview
Concepts

Download Trigger

Used to trigger a download of a file or data

Anatomy

import { DownloadTrigger } from '@chakra-ui/react'
<DownloadTrigger data="..." fileName="sample.txt" mimeType="text/plain" />

Examples

Basic

Pass the data, fileName and mimeType props to the DownloadTrigger component to trigger a download of the data. Use the asChild prop to render a custom trigger, like a Button.

Promise

The data prop also accepts a function that returns a Promise. The promise is resolved before the download starts, which is useful for downloading data that is generated or fetched on demand.

Props

PropDefaultType
data *
DownloadableData | (() => MaybePromise<DownloadableData>)

The data to download. Accepts a string, Blob or File, or a function that returns one of these (optionally async).

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.

For more details, read our Composition guide.