Components
Download Button
A button-styled download link with a file name hint.
Installation
$ npx veil-ui@latest add download-buttonUsage
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.
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | — | File URL to download. |
| download | boolean | string | "" | Suggested file name. The attribute is always present, even if empty. |
| label | string | "Download" | Visible label when no children are given. |
| ...props | React.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”.
downloadis 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>