Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Action Button
  3. API and Development

Action Button

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import ActionButton from @prepared911/ui/action-button. ActionButtonProps is ActionButtonOwnProps plus the Button layout props except trailing, the native form attributes Button forwards, data-* attributes, and the shared interaction props (disabled, active, id, the aria-* set, and the pointer, focus, keyboard, and click handlers).
PropTypeDefaultDescription
idleLabelLocalizedMessagerequiredLabel at rest
pendingLabelLocalizedMessagerequiredLabel while onAction is pending; announced
successLabelLocalizedMessagerequiredLabel during the success hold; announced
onAction() => Promise<unknown> | unknownrequiredWork to run on click
onActionError(error: unknown) => voidnoneCalled with the rejection after the button is idle
intentButtonIntentNeutralPaint intent
variantButtonVariantSoftSurface treatment
sizeButtonSizeLargeControl height
leadingReactNodenoneIcon or content before the label
tooltipLocalizedMessagenoneTooltip text, as on Button
disabledbooleanfalseNative disabled; unrelated to pending
type"button" | "submit" | "reset""button"Native button type
refRef<HTMLButtonElement>noneRef to the button
Not accepted: children, trailing, loading, loadingLabel, icon, label, and the toggle props.
Phases
The phase is internal: idle, pending, success. It shows on the DOM as the visible label, aria-busy and aria-disabled while pending, and the status region text.
Props
NameTypeDefaultDescription
idleLabelLocalizedMessage—Label at rest.
onAction() => unknown—Runs on click while the button is idle or showing success. The button is pending until the returned promise settles: a resolved promise shows the success state, a rejected one (or a synchronous throw) returns to idle and calls {@link ActionButtonOwnProps.onActionError}. A synchronous return counts as resolved. @returns A promise to wait for, or nothing
pendingLabelLocalizedMessage—Label while onAction is pending. Announced to assistive technology when it appears.
successLabelLocalizedMessage—Label while the success state shows. Announced to assistive technology when it appears.
activeboolean—Non-toggle pressed or transient current marker; hosts write the pressed state key through stateAttributes (data-pressed). A toggle host (Button toggle variant) uses aria-pressed and styles with [aria-pressed="true"] without also writing data-pressed for that toggle state (ADR 0001 rule 1). Link "current" within a set uses aria-current, not active.
aria-controlsstring—Id of the element controlled by this control.
aria-currentboolean | "time" | "false" | "true" | "page" | "step" | "location" | "date"—Whether this item is current within a set.
aria-describedbystring—Id of the element that describes this control.
aria-descriptionLocalizedMessage—Accessible description when it cannot be referenced by id.
aria-expandedboolean—Whether the controlled region is expanded.
aria-haspopupboolean | "dialog" | "menu" | "false" | "true" | "listbox" | "tree" | "grid"—Type of popup triggered by this control, if any.
aria-labelLocalizedMessage—Accessible name when the visible label is insufficient.
aria-labelledbystring—Id of the element that names this control.
classNamestring—Classes appended after generated paint classes.
disabledboolean—Inert state per host: native disabled on a button; on Link, ADR 0006 link host (no href, aria-disabled="true", tabIndex={0}). Never tabIndex={-1}.
idstring—Element id for ARIA relationships.
intentButtonIntent—Visual intent. Defaults to {@link ButtonIntent.Neutral}.
leadingReactNode—Content before the label.
onActionError((error: unknown) => void)—Called with whatever onAction rejected or threw. The button has already returned to idle. The button shows no error state of its own, so report the failure here (a toast, a field error). @param error - The rejection reason
preventFocusOnPressbooleanfalseWhen true, mousedown does not move focus to the button (field adornments).
refRef<HTMLButtonElement>—Ref to the rendered button.
sizeButtonSize—Control size. Defaults to {@link ButtonSize.Large}.
tooltipLocalizedMessage—Short text shown in a Tooltip while the pointer hovers the button or a navigation key focuses it. Button composes Tooltip's trigger, content and root, so it behaves like Tooltip > TooltipTrigger > Button and also works while disabled (pointer only) and on toggle buttons. A labelled button points aria-describedby at the tooltip. An icon-only button does not: label already names it, so the tooltip is visual only and never read twice. Adding or removing the prop after mount remounts the button.
type"button" | "submit" | "reset"—Native button type. Defaults to button.
variantButtonVariant—Surface variant. Defaults to {@link ButtonVariant.Soft}.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Action Button / Usage
Next
Action Button / Accessibility
On this page
Phases
Props
Storybook