Button

Alignment target:@astryxdesign/core v0.7.1 · Button

<Button
  label="Save changes"
  variant="primary"
  size="md"
  elevation="none"
/>

Button Props #

NameTypeDefaultDescription
labelstringrequiredNames the action and becomes visible text when no default slot is present.
variant'primary' | 'secondary' | 'ghost' | 'destructive''secondary'Visual hierarchy and semantic variant.
size'sm' | 'md' | 'lg''md'Button size.
elevation'none' | 'low' | 'med' | 'high''none'Resting shadow depth for a standalone floating button; ButtonGroup owns it inside a group.
type'button' | 'submit' | 'reset''button'Native button type.
namestring—Form submission name.
valuestring | number | readonly string[]—Form submission value.
formstring—ID of the associated form.
isDisabledbooleanfalseDisables interaction. The button never uses the native disabled attribute: it is marked aria-disabled and stays in the Tab order, so keyboard and screen-reader users can still reach it.
isLoadingbooleanfalseShows loading state, sets aria-busy, and disables non-interruptible activation.
isInterruptiblebooleanfalseAllows clickAction to run again while earlier work is pending.
clickAction(event: MouseEvent) => void | Promise<void>—Action function that automatically drives pending state.
isIconOnlybooleanfalseShows only the icon slot and uses label to name the button.
widthnumber | string—Button width. Numbers become pixels; CSS strings are used as supplied. When a row is too narrow the label truncates with an ellipsis and shows in full in a tooltip on keyboard focus.
loadingLabelstring'Loading'Localized text used by the spinner and live region.
tooltipstring—Supplementary hint shown on hover and keyboard focus.
hrefstring—Renders the enabled root as a link when present.
asstring | Component'a'Custom Vue link component for href mode. It receives both href and to.
targetstring—Link browsing context.
relstring—Link relationship attribute.

Async actions #

  • @click runs before clickAction.
  • If @click calls event.preventDefault(), the component skips clickAction.
  • If clickAction returns a Promise, the component enters the loading state.
  • When the Promise fulfills or rejects, the component clears the loading state.
  • The application must catch errors inside clickAction.

Repeated activation #

  • If isInterruptible is false, loading blocks another activation.
  • If isInterruptible is true, loading permits another activation.
  • Repeated activation runs multiple actions concurrently.
  • The component does not cancel earlier Promises.

To cancel an earlier network request, call AbortController.abort() in the application.

Button Slots #

NameDescription
defaultOptional visible-content override. label remains the stable accessible name.
iconDecorative icon before the label.
endShort trailing decoration such as a badge or icon. Ignored in icon-only mode.

Button Events #

NamePayloadDescription
clickMouseEventCancellable Vue component event. It is not emitted while disabled, non-interruptible loading, or deduplicated.

Template ref #

Button exposes element. Its type is HTMLButtonElement | HTMLAnchorElement | HTMLElement | null. In link mode (with href and not disabled) it is the link element: the anchor, or the root element of the as link component. Otherwise it is the button.

Native attributes #

The root element receives:

  • HTML attributes.
  • aria-* attributes.
  • data-* attributes.
  • class.
  • style.
  • Native event listeners.