# Download Trigger URL: https://ark-ui.com/docs/utilities/download-trigger Source: https://raw.githubusercontent.com/chakra-ui/ark/refs/heads/main/website/src/content/pages/utilities/download-trigger.mdx 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. **Example: basic** #### React ```tsx import { DownloadTrigger } from '@ark-ui/react/download-trigger' export const Basic = () => { return ( Download txt ) } ``` #### Solid ```tsx import { DownloadTrigger } from '@ark-ui/solid/download-trigger' export const Basic = () => { return ( Download txt ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Download txt ``` ### Download SVG Here's an example of how to download an SVG file. **Example: svg** #### React ```tsx import { DownloadTrigger } from '@ark-ui/react/download-trigger' export const Svg = () => { return ( Download SVG ) } ``` #### Solid ```tsx import { DownloadTrigger } from '@ark-ui/solid/download-trigger' export const Svg = () => { return ( Download SVG ) } ``` #### Vue ```vue ``` #### Svelte ```svelte `} fileName="circle.svg" mimeType="image/svg+xml" > Download SVG ``` ### Promise You can also trigger downloads from a promise that returns a `Blob`, `File`, or `string`. **Example: with-promise** #### React ```tsx import { DownloadTrigger } from '@ark-ui/react/download-trigger' export const WithPromise = () => { const fetchImage = async () => { const response = await fetch('https://picsum.photos/200/300') return response.blob() } return ( Download Image ) } ``` #### Solid ```tsx import { DownloadTrigger } from '@ark-ui/solid/download-trigger' export const WithPromise = () => { const fetchImage = async () => { const response = await fetch('https://picsum.photos/200/300') return response.blob() } return ( Download Image ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Download Image ``` ## API Reference **Component API Reference** #### React **DownloadTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `data` | `DownloadableData | (() => MaybePromise)` | Yes | The data to download | | `fileName` | `string` | Yes | The name of the file to download | | `mimeType` | `FileMimeType` | Yes | The MIME type of the data to download | | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | #### Solid **DownloadTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `data` | `DownloadableData | (() => MaybePromise)` | Yes | The data to download | | `fileName` | `string` | Yes | The name of the file to download | | `mimeType` | `FileMimeType` | Yes | The MIME type of the data to download | | `asChild` | `(props: ParentProps<'button'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | #### Vue **DownloadTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `data` | `DownloadableData | (() => MaybePromise)` | Yes | The data to download | | `fileName` | `string` | Yes | The name of the file to download | | `mimeType` | `FileMimeType` | Yes | The MIME type of the data to download | | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | #### Svelte **DownloadTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `data` | `DownloadableData | (() => MaybePromise)` | Yes | | | `fileName` | `string` | Yes | | | `mimeType` | `FileMimeType` | Yes | | | `asChild` | `Snippet<[PropsFn<'button'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | |