Design guidance
Buttons communicate an action that will occur when the user triggers them. The visual weight โ filled, outline, or quiet โ signals the action's importance relative to other elements on the page.
Visual hierarchy
Use no more than one primary (filled) button per view. Secondary and quiet buttons de-emphasize less critical actions so the primary action is clear.
Sizes
Spectrum buttons come in five sizes: XS, S, M (default), L, and XL. Match the size to the surrounding content density and target area requirements.
States
| State | Description |
|---|---|
default | The button's resting state. |
hover | Mouse pointer is over the button. |
pressed | Active click / touch state. |
focus | Keyboard or programmatic focus. |
disabled | Button is non-interactive. Use isDisabled prop. |
pending | Async action in progress (S2). Shows a spinner. |
React Spectrum implementation
Basic button
import {Button} from '@react-spectrum/s2'; function Example() { return ( <Button variant="accent" onPress={handlePress}> Save changes </Button> ); }
ActionButton with icon
import {ActionButton} from '@react-spectrum/s2'; import EditIcon from '@react-spectrum/s2/icons/Edit'; <ActionButton> <EditIcon /> <Text>Edit</Text> </ActionButton>
ToggleButton
import {ToggleButton} from '@react-spectrum/s2/ToggleButton'; import {useState} from 'react'; import Star from '@react-spectrum/s2/icons/Star'; function StarToggle() { const [selected, setSelected] = useState(false); return ( <ToggleButton aria-label="Star" isSelected={selected} onChange={setSelected}> <Star /> </ToggleButton> ); }
Key props โ Button (S2)
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'accent' | 'primary' | 'secondary' | 'negative' | 'primary' | Visual style / importance. |
style | 'fill' | 'outline' | 'fill' | Filled vs outlined. |
size | 'XS'|'S'|'M'|'L'|'XL' | 'M' | Size of the button. |
isPending | boolean | false | Shows spinner while async op runs (S2). |
isDisabled | boolean | false | Disables interaction. |
onPress | (e: PressEvent) => void | โ | Called on pointer/keyboard activation. |
Accessibility
Spectrum buttons are built on React Aria, providing keyboard, pointer, and screen-reader support out of the box.
- Always provide a meaningful label โ either visible text or
aria-labelfor icon-only buttons. - Use
isDisabledinstead of HTMLdisabledto preserve tab order and aria state. - For async actions,
isPendingcommunicates the loading state to screen readers automatically.