Components · Actions
Button
Triggers an action or event. Supports multiple variants, sizes, and semantic tones.
import { Button } from '@nexub/react';Usage
Triggering a primary or secondary action (submit, save, confirm)
Navigating users to another page or step in a flow
Opening a dialog, drawer, or modal overlay
Destructive actions that need a visible, labelled control
Inline text navigation — use a Link instead
Icon-only controls — use IconButton for touch target compliance
Selecting among multiple options — use ToggleGroup or SegmentedControl
Passive information display with no action
Playground
Playground
Live<Button variant="filled" size="md">Click me</Button>Examples
Default
Variants
Sizes
States
Async
Drive `status` from the request. Each click here moves to the next status.
Hero (marketing mode)
Inside `data-mode="marketing"` with `@nexub/themes/marketing` loaded. The focus ring sits outside the gradient.
Magnetic
`magnetic` (4.3): drifts toward the pointer. Use it for one key action per screen.
States
defaultdisabled- Loading
loading size="sm"size="md"size="xs"size="lg"size="xl"variant="glass"variant="filled"variant="tonal"variant="outlined"variant="text"variant="hero"variant="subtle"variant="destructive"tone="neutral"tone="info"tone="success"tone="warning"tone="danger"tone="leap"tone="bookub"tone="payub"
Variant matrix
| variant ↓ / size → | xs | sm | md | lg | xl |
|---|---|---|---|---|---|
| filled | |||||
| outlined | |||||
| text | |||||
| subtle | |||||
| link |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | 'glass' | 'filled' | 'tonal' | 'outlined' | 'text' | 'hero' | 'subtle' | 'destructive' | 'accent' | 'link' | 'filled' | Visual style of the button. hero is the marketing-mode main button (gradient, glow, spring lift): a filled button outside data-mode="marketing"; one per screen. Deprecated in 8.4, removed in 9.0: the legacy aliases primary (filled), secondary (tonal), outline (outlined) and ghost (text) still work; npx nexub-migrate --rules button-aliases --write renames them. |
| size | 'sm' | 'md' | 'xs' | 'lg' | 'xl' | 'md' | Control height and padding. |
| status | 'idle' | 'error' | 'success' | 'loading' | — | Async feedback (beta, 1.7.0). loading shows a spinner and blocks clicks but keeps focus; success draws a check; error shakes once. The label stays in flow, so the width holds. |
| loading | boolean | — | Alias for status="loading". |
| loadingLabel | string | 'Loading' | Announced when status becomes loading. |
| successLabel | string | 'Done' | Announced on success. When set, it also replaces the visible label (with a check) instead of showing the check alone. |
| errorLabel | string | 'Something went wrong' | Announced on error. |
| disabled | boolean | false | Disables the button. |
| magnetic | boolean | false | 4.3: drifts a few pixels toward the pointer on hover. For one key action per screen. Off for touch and reduced motion. |
| fullWidth | boolean | — | Stretches the button to fill its container. |
| leadingIcon | React.ReactNode | — | Icon rendered before the label. |
| trailingIcon | React.ReactNode | — | Icon rendered after the label. |
| tone | 'neutral' | 'info' | 'success' | 'warning' | 'danger' | 'leap' | 'bookub' | 'payub' | 'founderub' | — | Semantic colour tone — overrides the variant colour with a semantic palette. |
| asChild | boolean | false | Merges props onto the immediate child element (Radix Slot). status and loading have no effect with asChild. |
Design tokens
Button reads these component tokens. Each one is unset by default and falls back to the semantic role it aliases, so nothing changes until you set it. Set one on any element to restyle every Button below it, and leave the roles other components share alone. See the three token tiers.
| Token | Aliases | Notes |
|---|---|---|
| --button-filled-bg | --color-primary | — |
| --button-filled-fg | --color-on-primary | — |
| --button-tonal-bg | --color-secondary-container | — |
| --button-tonal-fg | --color-on-secondary-container | — |
| --button-outlined-border | --color-outline-variant | — |
| --button-outlined-fg | --color-on-surface | — |
| --button-text-fg | --color-on-surface | — |
/* One area of your app */
.checkout {
--button-filled-bg: var(--color-secondary);
}Accessibility
ARIA roles
Keyboard
- Space
Activates the focused button.
- Enter
Activates the focused button.
- Tab
Moves focus to the button in document order.
Focus
Receives focus in document order; `disabled` removes it from the tab sequence.
Visible focus ring uses `--color-border-focus` and meets WCAG 2.4.7 contrast.
Screen reader
Announces the visible label plus the implicit "button" role.
While loading the button sets `aria-busy` and `aria-disabled` (not `disabled`), so focus stays on it and clicks are ignored.
A button with `status` or `loading` renders a polite `role="status"` region next to it that announces `loadingLabel`, `successLabel` or `errorLabel` as the status changes.
Notes
Pair icon-only triggers with `IconButton` for a 44×44 touch target.
On iOS & Android: Button
import { Button } from '@nexub/react-native';
import { Send } from '@nexub/icons/native';
<Button size="lg" leadingIcon={Send} onPress={send} loading={sending}>
Send money
</Button>Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Variants | filled, tonal, outlined, text, glass, plus subtle, link, destructive, accent. | filled, tonal, outlined, text, glass. Use tone="danger" for destructive. |
| Icons | Icon elements as children or leadingIcon. | leadingIcon / trailingIcon take an icon component from @nexub/icons/native. |
| Primary action size | md (40px) by default. | Use lg (48pt) for the main action on a screen. |
| Feedback | Hover and focus state layers; press scales to 0.97. | Pressed state layer, 0.97 press spring, semantic haptic. No hover. |
| Hit area | Visual size; xs/sm controls meet WCAG 2.5.8 (24px). | Always 44pt, extended with hitSlop when the visual is smaller. |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
Button props
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | — |
| variant | 'filled' | 'tonal' | 'outlined' | 'text' | 'glass' | 'hero' | 'filled' | — |
| tone | ToneValue | — | Solid semantic or product colour (overrides the variant colour). |
| size | ControlSize | 'md' | The control ladder. Primary actions on mobile use 'lg' (48). |
| loading | boolean | false | Shows a spinner (after 150ms, for at least 400ms), blocks presses at once and announces loadingLabel. Same as status="loading". |
| loadingLabel | string | 'Loading…' (the provider's `loading` message) | Announced while loading. |
| status | 'idle' | 'loading' | 'success' | 'error' | 'idle' | Async feedback, as on web. loading shows a spinner and blocks presses, success
shows a check, error plays the error haptic. Screen readers hear each change.
Wins over loading. |
| successLabel | string | 'Done' | Announced on success. When given, it also replaces the visible label while status is success. |
| errorLabel | string | 'Something went wrong' | Announced on error. |
| fullWidth | boolean | — | — |
| leadingIcon | React.ComponentType<NativeIconProps> | — | — |
| trailingIcon | React.ComponentType<NativeIconProps> | — | — |
| style | StyleProp<ViewStyle> | — | — |
| haptic | 'selection' | 'toggleOn' | 'toggleOff' | 'confirm' | 'success' | 'reject' | 'warning' | 'snap' | — | Haptic played on press (Apple: not for plain taps — toggles, selections, outcomes). |
| stateLayer | RoleName | false | 'on-surface' | On-colour of the state layer, or false for none. |
| pressScale | number | false | 0.97 | Press-scale target, or false for none. |