Download Trigger
Used to trigger a download of a file.
Usage
import { DownloadTrigger } from "@chakra-ui/react"<DownloadTrigger data="..." fileName="x.png" mimeType="image/png" />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.
File Size
Compose the DownloadTrigger with the FormatByte component to display the
size of the file in a human-readable format.
Props
| Prop | Default | Type |
|---|---|---|
spinnerPlacement | start | 'start' | 'end' | undefinedThe placement of the spinner |
colorPalette | gray | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'The color palette of the component |
size | md | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'The size of the component |
variant | solid | 'solid' | 'subtle' | 'surface' | 'outline' | 'ghost' | 'plain'The variant of the component |
loading | boolean | undefinedIf `true`, the button will show a loading spinner. | |
loadingText | React.ReactNode | undefinedThe text to show while loading. | |
spinner | React.ReactNode | undefinedThe spinner to show while loading. | |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |