Icon Button
The icon-only preset of Button:
iconOnly makes it square and sizes the glyph; all variants apply. It is the
same component — a dismiss “×” is just iconOnly + a glyph + an ariaLabel.
Import
Section titled “Import”<script> import Button from "@invisible-ui/svelte/Button.svelte"; import Icon from "@invisible-ui/svelte/Icon.svelte";</script><script setup> import { Button, Icon } from "@invisible-ui/vue";</script>import { Button, Icon } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-button></ds-button><ds-icon></ds-icon>| 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”ariaLabelis mandatory: with no visible text, the accessible name must come from somewhere — the demo’s “Close”, “Add”, “Delete” are what screen readers announce.- The hit area keeps the WCAG minimum target size via
--ds-components-button-icon-min-size.
Example
Section titled “Example”<Button iconOnly variant="ghost" ariaLabel="Close" onpress={() => dismiss()}> <Icon><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></Icon></Button>Themeable via --ds-components-button-icon-min-size, --ds-components-button-icon-size,
--ds-components-button-spacing-icon (plus the shared --ds-components-button-*).
A count or a status dot can sit on the button’s corner. In Elements, add a
<ds-count slot="badge">: it renders beside the button, not inside it, so the
button keeps its own name and the count describes it.
<ds-button icon-only variant="ghost" aria-label="Notifications"> <svg viewBox="0 0 24 24" aria-hidden="true">…</svg> <ds-count slot="badge" count="3" label="3 unread notifications"></ds-count></ds-button>