Veil UI
Components

Download Button

A button-styled download link with a file name hint.

Installation

$ npx veil-ui@latest add download-button

Usage

import { DownloadButton } from "@/components/ui/download-button";

<DownloadButton href="/files/report.pdf" download="report.pdf">
  Download report
</DownloadButton>;

Examples

Basic

File name

Outline

API reference

DownloadButton renders an anchor styled as a button and always sets the download attribute.

PropTypeDefaultDescription
hrefstring—File URL to download.
downloadboolean | string""Suggested file name. The attribute is always present, even if empty.
labelstring"Download"Visible label when no children are given.
...propsReact.ComponentProps<"a">—All native anchor attributes.

Accessibility

  • It is a real link, so it supports open-in-new-tab, copy-link and the browser context menu.
  • Add a descriptive label that names the file, not just “Download”.
  • download is ignored for cross-origin URLs by most browsers.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add download-button --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { Download } from "lucide-vue-next";

import { Button } from "@/components/ui/button";
import type { ButtonVariants } from "@/components/ui/button";

defineOptions({ inheritAttrs: false });

const props = withDefaults(
  defineProps<{
    label?: string;
    download?: string;
    variant?: ButtonVariants["variant"];
    size?: ButtonVariants["size"];
    class?: string;
  }>(),
  { label: "Download" },
);
</script>

<template>
  <Button
    as-child
    :variant="variant"
    :size="size"
    data-slot="download-button"
    :class="props.class"
  >
    <a v-bind="$attrs" :download="download ?? ''">
      <Download aria-hidden="true" />
      <slot>{{ label }}</slot>
    </a>
  </Button>
</template>

On this page