Button

A composable button primitive for actions, links, and custom elements.

Features

  • Polymorphic rendering
  • Native, link, or custom modes
  • Semantic disabled behavior
  • Button groups with position tracking
  • Headless styling

Installation

npm install @ariaui/button

Examples

Each variant has its own live preview and snippet. Style Button.Root directly, or pass asChild and style the slotted link via className.

Primary

The default filled button for common actions.

Preview

No preview output yet.

live.tsxReady

Secondary

Use for less prominent actions.

Preview

No preview output yet.

live.tsxReady

Destructive

Use for actions that remove data or have high impact.

Preview

No preview output yet.

live.tsxReady

Outline

Use for neutral actions that still need a visible boundary.

Preview

No preview output yet.

live.tsxReady

Ghost

Use for lightweight actions that should stay visually quiet.

Preview

No preview output yet.

live.tsxReady

Use when button styling should read like a text link.

Preview

No preview output yet.

live.tsxReady

With icon

Icons can sit to the left or right of the label.

Preview

No preview output yet.

live.tsxReady

Loading

Disabled state with a spinner while an action is in progress.

Preview

No preview output yet.

live.tsxReady

Sizes

Small, default, and large heights with matching padding.

Preview

No preview output yet.

live.tsxReady

Anatomy

tsx
import * as Button from "@ariaui/button";

export default function Example() {
  return <Button.Root />;
}

API Reference

Root

Composable button primitive. Defaults to a native `<button>`. Pass `asChild` with a single child element for link or custom-element rendering.

PropTypeDefault
asChild
booleanfalse
type
"button" | "submit" | "reset""button"
disabled
booleanfalse
AttributeValues
[data-disabled]Present when disabled

Group

Structural container for related buttons. Provides context for descendant `Button.Item` registration. Renders a `<div>`.

PropTypeDefault
role
string"group"
aria-label
string

Item

Grouped button primitive for use inside `Button.Group`. Shares all composition and disabled behavior with `Root`. Automatically derives and reflects its position within the group via `data-position`.

PropTypeDefault
asChild
booleanfalse
disabled
booleanfalse
AttributeValues
[data-position]"only" | "first" | "middle" | "last" — derived automatically from group order
[data-disabled]Present when disabled

Keyboard

ShortcutAction
TabMove focus to the next focusable element.
Shift+TabMove focus to the previous focusable element.
EnterTrigger the button's click event.
SpaceTrigger the button's click event. For custom non-native elements, fires on keyup to avoid page scroll.

Native <button> and <a> elements follow standard browser keyboard behavior. Custom non-native elements support manual Enter and Space activation.

Accessibility

The Button component renders semantic controls across three modes:

Native <button> elements use the standard disabled attribute. For navigation, pass asChild and render a real anchor or router link as the child; disabled anchors have their href removed and receive aria-disabled="true". Custom children receive role="button", tabIndex={0}, and manual keyboard activation for Enter and Space.

Button.Group and Button.Item are useful for grouping related actions. Items expose their position through data-position, which supports position-aware styling such as first and last item radius adjustments.

Previous
Breadcrumb