Button

Triggers an action, submits a form or — with an href — navigates while looking like a button. Seven variants, three appearances and five sizes, all drawn from theme tokens.

  • vig-button
  • [vigButtonIcon]
Import
import { Button, ButtonIcon } from '@vigdx/ui/button';

Variants

variant picks the hue from the shared set: primary (default), secondary , ghost and the four status colors.

Appearances

appearance sets the emphasis: solid (default), outlined and text . Combine it with any variant.

Sizes

size runs from xs (24px) to xl (48px); md (34px) is the default control height.

Icons

Project any 1em icon marked with vigButtonIcon . Without a label the button turns square — give it an ariaLabel ; rounded makes it a circle.

Loading and disabled

loading swaps the icon for a spinner, sets aria-busy and blocks clicks while keeping the variant colors and focus. disabled greys the button out.

With an href the button renders an <a> . target="_blank" adds rel="noopener noreferrer" ; a disabled link drops its href and leaves the tab order.

Full width

fullWidth stretches the button across its container, e.g. in narrow forms.

All variants

Every variant in every appearance, plus the disabled state.

Every variant in every appearance
Variant solid outlined text disabled
primary
secondary
ghost
info
success
warning
error

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="button"][data-part="control"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="button"]

Button styling hooks
Part Element data-state
control The native <button> , or <a> with href . —
spinner The busy ring while loading . —
icon Wrapper of the [vigButtonIcon] slot. —

Accessibility

  • Renders a native <button> (type="button" by default, so it never submits a form by accident) or, with href, a native <a>. Both activate with Enter; buttons also with Space.
  • Icon-only buttons have no visible text: always pass ariaLabel. A vigTooltip with the same text helps sighted mouse users.
  • loading sets aria-busy="true" and blocks activation, but keeps the button focusable (aria-disabled="true" instead of disabled), so a focused submit button that starts loading does not drop focus to the page; a disabled link gets aria-disabled="true" and tabindex="-1".
  • Focus is always visible: a --shadow-focus halo on filled and outlined buttons, the offset --shadow-focus-ring on borderless ones.
  • Every variant meets WCAG AA contrast against its fill in the light and dark palettes.

API

Button

vig-button component
Button props
Name Type Default Description
appearanceButtonAppearance'solid'
—
ariaLabelstring | undefinedundefined

Accessible name — required for icon-only buttons, overridable for i18n.

autofocusbooleanfalse

Sets autofocus on the inner control, so a native <dialog> focuses it when it opens — e.g. the safe action of a destructive confirmation.

disabledbooleanfalse
—
fullWidthbooleanfalse

Stretches the button across its container (e.g. form submit rows).

hrefstring | undefinedundefined

Renders a link (<a>) with the button's look instead of a <button>. disabled then drops the href and marks the link aria-disabled.

labelstring | undefinedundefined
—
loadingbooleanfalse

Shows a spinner in place of the icon and blocks activation. The button keeps focus while busy: it is marked aria-disabled rather than natively disabled.

relstring | undefinedundefined

Link rel; defaults to noopener noreferrer for target="_blank".

roundedbooleanfalse

Pill shape; combined with an icon-only button it renders a circle.

sizeButtonSize'md'
—
targetstring | undefinedundefined

Link target, e.g. _blank; only applies with href.

type"button" | "submit" | "reset"'button'
—
variantButtonVariant'primary'
—

Templates and directives

Templates and directives
Selector Export Description
[vigButtonIcon]ButtonIcon

Marks projected content as the button's leading icon. Any icon source works (icon font <i>, inline <svg>) as long as it sizes at 1em. A button with an icon and no label renders square (icon-only) and must be given an ariaLabel.

Are you sure?