File size: 1,136 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: Download Trigger
description: Used to trigger a download of a file.
links:
  source: components/download-trigger
  storybook: components-download-trigger--basic
  ark: https://ark-ui.com/docs/utilities/download-trigger
---

<ExampleTabs name="download-trigger-basic" />

## Usage

```jsx
import { DownloadTrigger } from "@chakra-ui/react"
```

```jsx
<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.

<ExampleTabs name="download-trigger-basic" />

### Download SVG

Here's an example of how to download an SVG file.

<ExampleTabs name="download-trigger-svg" />

### Promise

You can also trigger downloads from a promise that returns a `Blob`, `File`, or
`string`.

<ExampleTabs name="download-trigger-with-promise" />

### File Size

Compose the `DownloadTrigger` with the `FormatByte` component to display the
size of the file in a human-readable format.

<ExampleTabs name="download-trigger-with-file-size" />

## Props

<PropTable component="DownloadTrigger" />