Skip to content

Button

The styled, batteries-included button, carrying a semantic variant (what the action means, not a style): default, primary, secondary, danger, ghost.

Two presets have their own pages: Icon Button (square, icon-only) and Loading Button (in-flight state with announcements).

<script>
import Button from "@invisible-ui/svelte/Button.svelte";
</script>
PropTypeDefaultDescription
actionAction<HTMLElement>() => {}Optional extra Svelte action applied to the underlying <button>. Overlay components (Dialog, Popover, …) pass their triggerAction here to compose the Button as their trigger.
variantButtonVariant"default"
disabledbooleanfalse
loadingbooleanfalseLoading state: shows an inline spinner in place of the leading icon (or of the glyph, for icon-only buttons), announces aria-busy and ignores presses. The label stays visible and the button stays focusable.
loadingStatusstring | undefinedundefinedLive loading message announced on every change while loading — for a succession of backend-reported steps ("Uploading…" → "Processing…"). It is visually hidden (the button label stays stable); assistive tech hears each step through the spinner's polite status region.
type"button" | "submit" | "reset""button"
onpress((event: Event) => void) | undefinedundefinedCalled when activated (click, or Enter/Space).
copystring | undefinedundefinedText to copy to the clipboard when the button is pressed. After a successful copy, a confirmation shows beside the button for two seconds and is announced politely (ADR 0016).
copiedLabelstring | undefinedundefinedThe confirmation shown after a copy. Defaults to the i18n catalog's "Copied".
leftIconboolean | undefinedundefinedShow a leading icon. Defaults on for danger.
rightIconbooleanfalseShow a trailing icon.
iconOnlybooleanfalseSquare, icon-only button (pass one icon as children + an ariaLabel). The CloseButton is a preset of this.
ariaLabelstring | undefinedundefinedAccessible name; required for icon-only buttons.
leftSnippet | undefinedundefinedReplaces the built-in leading icon.
rightSnippet | undefinedundefinedReplaces the built-in trailing icon.
  • Every button needs an accessible name: visible text (default slot) or ariaLabel for icon-only buttons.
  • danger shows a hazard icon by default, so meaning never relies on color alone (WCAG 1.4.1).
  • Behaviour and a11y (focus, Enter/Space activation) come from the headless button.

In every adapter, copy holds text for the button to copy. After a successful copy, “Copied” (or copied-label, copiedLabel in Svelte, Vue and React) shows beside the button for two seconds, announced through a polite live region; the button keeps its name and focus. Nothing shows when the clipboard refuses the text. It is the confirmation at the source that ADR 0016 asks for inside a dialog.

<Button copy="https://example.com/reports/q3" copiedLabel="Link copied">Copy the link</Button>
<ds-button copy="https://example.com/reports/q3" copied-label="Link copied">Copy the link</ds-button>

In Vue, the same props are copy and copiedLabel:

<Button copy="https://example.com/reports/q3" copied-label="Link copied">Copy the link</Button>

In React, the props are copy and copiedLabel:

<Button copy="https://example.com/reports/q3" copiedLabel="Link copied">
Copy the link
</Button>
<Button variant="primary" onpress={() => save()}>Save changes</Button>

Themeable via --ds-components-button-*.