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).
Import
Section titled “Import”<script> import Button from "@invisible-ui/svelte/Button.svelte";</script><script setup> import { Button } from "@invisible-ui/vue";</script>import { Button } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-button></ds-button>| Prop | Type | Default | Description |
|---|---|---|---|
action | Action<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. |
variant | ButtonVariant | "default" | |
disabled | boolean | false | |
loading | boolean | false | Loading 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. |
loadingStatus | string | undefined | undefined | Live 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) | undefined | undefined | Called when activated (click, or Enter/Space). |
copy | string | undefined | undefined | Text 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). |
copiedLabel | string | undefined | undefined | The confirmation shown after a copy. Defaults to the i18n catalog's "Copied". |
leftIcon | boolean | undefined | undefined | Show a leading icon. Defaults on for danger. |
rightIcon | boolean | false | Show a trailing icon. |
iconOnly | boolean | false | Square, icon-only button (pass one icon as children + an ariaLabel). The CloseButton is a preset of this. |
ariaLabel | string | undefined | undefined | Accessible name; required for icon-only buttons. |
left | Snippet | undefined | undefined | Replaces the built-in leading icon. |
right | Snippet | undefined | undefined | Replaces the built-in trailing icon. |
| Prop | Type | Default | Description |
|---|---|---|---|
variant | ButtonVariant | "default" | Semantic variant, surfaced as data-variant: default (baseline) · primary (the action that moves the flow forward) · secondary (alternative emphasized action) · ghost (low emphasis) · danger (destructive: shows a hazard icon so meaning never rests on colour alone, WCAG 1.4.1). |
disabled | boolean | false | |
type | "button" | "submit" | "reset" | "button" | |
onPress | (event: Event) => void | undefined | Called when the button is activated. |
leftIcon | boolean | undefined | Show a leading icon. Defaults on for danger (the hazard cue). |
rightIcon | boolean | false | Show a trailing icon. |
iconOnly | boolean | false | Icon-only button: square, no text. Pass a single icon as the default slot and an ariaLabel. |
ariaLabel | string | undefined | Accessible name. Required for icon-only buttons; for buttons with visible text the text is the name and this is unnecessary. |
copy | string | undefined | Text copied to the clipboard when the button is activated. |
copiedLabel | string | undefined | The confirmation shown after a copy. Defaults to the catalog's "Copied". |
Slots: default, left, right.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | ButtonVariant | "default" | Semantic variant, surfaced as data-variant: default (baseline) · primary (the action that moves the flow forward) · secondary (alternative emphasized action) · ghost (low emphasis) · danger (destructive — shows a hazard icon so meaning never rests on colour alone, WCAG 1.4.1). |
disabled | boolean | false | |
type | "button" | "submit" | "reset" | "button" | |
onPress | (event: Event) => void | — | Called when the button is activated. |
leftIcon | boolean | — | Show a leading icon. Defaults on for danger (the hazard cue). |
rightIcon | boolean | false | Show a trailing icon. |
left | ReactNode | — | Replace the built-in leading glyph. |
right | ReactNode | — | Replace the built-in trailing glyph. |
iconOnly | boolean | false | Icon-only button: square, no text — pass a single icon as children and an ariaLabel. |
ariaLabel | string | — | Accessible name. Required for icon-only buttons; for buttons with visible text the text is the name and this is unnecessary. |
copy | string | — | Text the button copies to the clipboard when pressed (ADR 0016). After a successful copy, copiedLabel shows beside the button for two seconds, announced through a polite live region; the button keeps its name and focus. A refused clipboard shows nothing. |
copiedLabel | string | — | The confirmation shown after a copy. Defaults to the catalog's "Copied". |
children | ReactNode | — |
Also accepts NativeButtonProps.
| Attribute | Reactive | Description |
|---|---|---|
variant | yes | default|primary|secondary|ghost|danger |
disabled | yes | |
type | yes | button|submit|reset |
icon-only | yes | |
left-icon | yes | |
right-icon | yes | |
aria-label | yes | forwarded — required for icon-only |
aria-haspopup | yes | |
aria-controls | yes | |
title | yes | |
copy | yes | text copied on activation |
copied-label | yes | the confirmation shown after a copy, "Copied" by default |
Reactive attributes re-render the element when they change after the first render.
Accessibility
Section titled “Accessibility”- Every button needs an accessible name: visible text (default slot) or
ariaLabelfor icon-only buttons. dangershows 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.
Copy confirmation
Section titled “Copy confirmation”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>Example
Section titled “Example”<Button variant="primary" onpress={() => save()}>Save changes</Button>Themeable via --ds-components-button-*.