DocsBlog

Get Started

Components

Data Grid

Signals

Styling

Theming

↑↓Navigate
↵Select
EscClose
  • 1.8.0

  • Day

    Night

    Preview

    Switch mode
  • cerberus

    acheron

    elysium

    oceanus

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

OverviewCompositionCerberus ContextTesting

Layout

Aspect RatioBleedBoxCenterContainerContainer QueryDividerFlexFloatGridGroupLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTA ModalDate PickerDialogFieldFieldsetFile UploaderIconButtonInputLoading StatesMarqueeMenuNotificationsNumber InputPaginationPin InputPopoverProgress IndicatorsPrompt ModalRadioRatingSelectSliderSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFormat Relative TimeFrameHighlightJSON Tree ViewLocalePortalPresenceShowSwapsplitPropsTheme

Download Trigger

Programmatically trigger file downloads

  • npm
View as Markdown
Open this page in Markdown
Anthropic
Open in Claude
Ask questions about this page
OpenAI
Open in ChatGPT
Ask questions about this page

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.

Loading example...

Download SVG

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

Loading example...

Promise

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

Loading example...

API

Props

PropTypeRequiredDefaultDescription
dataDownloadableData | (() => MaybePromise<DownloadableData>)trueundefinedThe data to download
fileNamestringtrueundefinedThe name of the file to download
mimeTypeFileMimeTypetrueundefinedThe MIME type of the data to download
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

On this page

  • Motivation
  • Examples
    • Basic
    • Download SVG
    • Promise
  • API
Edit this page on Github