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

Button

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Button is used to take action by clicking or pressing a specific key.
Props
NameTypeDefaultDescription
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. active paints data-pressed and conflicts with toggle aria-pressed; not on toggle buttons.
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.
childrenReactNode—Visible label. Visible label; omit for icon-only.
classNamestring—Classes appended after generated paint classes.
defaultPressedboolean—Initial on state when uncontrolled.
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}.
iconReactNode—Icon-only glyph; use with {@link ButtonIconOnlyProps} instead. Icon slot, usually {@link Icon }.
idstring—Element id for ARIA relationships.
intentButtonIntent—Visual intent. Defaults to {@link ButtonIntent.Neutral}.
labelLocalizedMessage—Icon-only accessible name; use with {@link ButtonIconOnlyProps} instead. Accessible name rendered through {@link VisuallyHidden }.
leadingReactNode—Content before the label.
loadingboolean—Composed loading state: disables the control, sets aria-busy, and shows a spinning loader glyph before the label. Loading is not defined for toggle buttons.
loadingLabelLocalizedMessage—Accessible name while loading; rendered through {@link VisuallyHidden }. Loading label is not defined for toggle buttons.
onPressedChange((pressed: boolean, details: ChangeDetails<ChangeReason>) => void)—Called when the toggle changes from a click or Enter/Space activation. @param pressed - Next pressed state @param details - Change metadata; cancel to keep the previous state
pressedboolean—Whether the toggle is on (controlled).
pressedIconReactNode—The pressed icon belongs to an icon-only toggle; see {@link ButtonToggleProps.pressedIcon}. Icon shown in place of icon while the toggle is on, for an icon-only toggle whose glyph shows the state (an outlined star that fills, a bell that gains a slash). The accessible name stays label in both states, and aria-pressed carries the state, so the glyph is never the only signal. Without it icon shows in both states. Not defined with children: a labelled button keeps one label and its leading and trailing slots.
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.
trailingReactNode—Content after the label.
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
Critical
Use to designate key actions, such as accepting a condition that changes the product state. Allow one critical button per page; don't use alongside a primary button.
Primary
Use for important actions like saving or creating something new. Allow one primary button per page; don't use alongside a critical button.
Secondary
Use in the interface for all actions except for those considered primary or critical.
Secondary (Alt)
Use occasionally as an alternative type to differentiate actions of lesser importance from those paired with primary and default buttons. Secondary buttons most often appear in buttons groups as the action of least importance.
Link
Navigation is Link from @prepared911/ui/link, not Button. Button has no href. Use variant={ButtonVariant.Plain} when the control is an action that should look like text. Use Link with appearance={LinkAppearance.Button} when a destination should look like a button.
Internal
Internal links open in the same browser tab.
External
Set external and newTabLabel. The link opens in a new tab and the label names that behavior.
Semantic Types
Semantic or color-coded buttons give users a sense of their purpose without even having to read their label.
Success
Use to indicate a constructive action or confirming a positive state (e.g., a completed process, approving an action).
Destructive
Use to indicate a destructive action or confirming a negative state (e.g., deleting or removing something, taking an irreversible action).
Split
A button with a downward-facing chevron as a tail icon, use in buttons with related actions instead of a button group. Split buttons can also include a lead icon.
Sizes
As with color, sizing also conveys a button's place in a page hierarchy.
Large (default)
Use frequently for most actions. This is the default when size is omitted.
Regular
Use when you need a slightly shorter control than large without going to the compact size.
Small
Use in tight spaces, such as sidebars and floating elements; only pair with other small-sized buttons.
Lead Icon
Use to identify or differentiate the button's usage, such as a "+" icon when adding something.
Tail Icon
Use to provide additional context about the button label or indicate what happens after clicking the button, such as an arrow "→" after "Next."
Loading
Use to indicate that an action is in process; reverts to the previous state when completed.
Disabled
Use for unavailable actions. Always provide context (via tooltip or nearby text) for why the action is unavailable and how to enable it.
Active
active marks a momentary or current control with data-pressed and does not set aria-pressed. Use pressed and onPressedChange when the control must stay pressed.
Toggle
Pass pressed or defaultPressed with onPressedChange. The button sets aria-pressed. There is no toggle prop and no separate toggle type. Do not change the visible name when the pressed state changes. Icon-only toggles use icon, label, and pressedIcon when the glyph changes. Do not use these props inside a ToggleGroup. Group items remain ToggleGroupItem.
Loading indicators
loading keeps the label visible, sets aria-busy, and disables the button. loadingLabel is the accessible name of the busy state. There is no loading-type enum.
Complete state
Progress on icon
Status dot
Previous
Button / Usage
Next
Button / Accessibility
On this page
Props
Storybook
Critical
Primary
Secondary
Secondary (Alt)
Link
Internal
External
Semantic Types
Success
Destructive
Split
Sizes
Large (default)
Regular
Small
Lead Icon
Tail Icon
Loading
Disabled
Active
Toggle
Loading indicators
Complete state
Progress on icon
Status dot