Button
Starts an action, navigates with the same surface, carries an action with no room for a label, or holds a state that stays on.
import { Button } from '@slotted/react/button';export default function ButtonBasic() { return <Button onClick={() => console.log('saved')}>Save changes</Button>;}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { Button, ButtonDefaultsProvider, ButtonLink, IconButton, ToggleButton } from '@slotted/react';Variants
solid marks the action a region exists for, outline a quieter action with a bounded edge, and ghost an action with no edge at all. Give a region one solid action and paint the rest outline or ghost in the secondary tone.
import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';export default function ButtonVariants() { return ( <Inline gap={2}> <Button>Publish invoice</Button> <Button tone="secondary" variant="outline"> Save draft </Button> <Button tone="secondary" variant="ghost"> Discard </Button> </Inline> );}Tones
Five semantic colors, each paintable in every variant. accent is the default; secondary is neutral; success, warning and danger say what the action does to the record, so a destructive action reads as one before it is pressed.
import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';export default function ButtonTones() { return ( <Stack gap={3}> <Inline gap={2}> <Button>Create order</Button> <Button tone="secondary">Export</Button> <Button tone="success">Approve</Button> <Button tone="warning">Hold shipment</Button> <Button tone="danger">Void invoice</Button> </Inline> <Inline gap={2}> <Button variant="outline">Create order</Button> <Button tone="secondary" variant="outline"> Export </Button> <Button tone="success" variant="outline"> Approve </Button> <Button tone="warning" variant="outline"> Hold shipment </Button> <Button tone="danger" variant="outline"> Void invoice </Button> </Inline> </Stack> );}Sizes
Three steps of the control scale. Each step reads the --slotted-control-* tokens, so the density the application sets retunes every button at once, and no state changes a button’s size.
import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';export default function ButtonSizes() { return ( <Inline align="center" gap={2}> <Button size="sm">Add line item</Button> <Button size="md">Add line item</Button> <Button size="lg">Add line item</Button> </Inline> );}Icons
start and end place content before and after the label, and mirror in a right-to-left document. An icon beside a label repeats it, so it stays hidden from assistive technology: the library’s Glyph already carries aria-hidden; give your own icon the attribute.
import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';export default function ButtonIcons() { return ( <Inline gap={2}> <Button start={<Glyph name="plus" />}>New order</Button> <Button start={<Glyph name="upload" />} tone="secondary" variant="outline"> Import CSV </Button> <Button end={<Glyph name="chevron-right" />} tone="secondary" variant="ghost"> Continue to payment </Button> </Inline> );}Icon buttons
IconButton is a square control for an action with no room for a label. Its accessible name comes from aria-label or aria-labelledby, and it is required: in React the type refuses a button without one, and in Angular the development build throws. It defaults to the neutral ghost paint, and shape="circle" rounds it.
import { IconButton } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';export default function ButtonIconButton() { return ( <Inline align="center" gap={2}> <IconButton aria-label="Copy invoice number"> <Glyph name="copy" /> </IconButton> <IconButton aria-label="Refresh balances" variant="outline"> <Glyph name="rotate-ccw" /> </IconButton> <IconButton aria-label="Delete draft" tone="danger"> <Glyph name="trash" /> </IconButton> <IconButton aria-label="Add note" shape="circle" tone="accent" variant="solid"> <Glyph name="plus" /> </IconButton> </Inline> );}Loading
While loading is set, the button refuses activation, keeps focus and its width, and announces a progress indicator named by messages.loading. A band in the button’s own ink sweeps behind the label and the icon. With reduced motion or forced colors, a ring replaces the band: in the start icon’s box, or over the label when there is no icon. loadingDelay holds both back for waits that end quickly, while the refusal starts at once. Press either button.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';export default function ButtonLoading() { const [syncing, setSyncing] = useState(false); const [sending, setSending] = useState(false); const sync = () => { setSyncing(true); setTimeout(() => setSyncing(false), 2000); }; const send = () => { setSending(true); setTimeout(() => setSending(false), 2000); }; return ( <Inline gap={2}> <Button loading={syncing} messages={{ loading: 'Syncing' }} onClick={sync} start={<Glyph name="rotate-ccw" />} tone="secondary" variant="outline" > Sync inventory </Button> <Button loading={sending} loadingDelay={300} messages={{ loading: 'Sending' }} onClick={send}> Send invoice </Button> </Inline> );}Disabled
disabled uses the platform attribute, which also removes the control from the tab sequence. Add focusableWhenDisabled when the reason a control is unavailable has to stay reachable: the button keeps its place in the tab order, announces aria-disabled, refuses activation, and can point at the explanation with aria-describedby.
import { useId } from 'react';import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function ButtonDisabled() { const hintId = useId(); return ( <Stack gap={2}> <Inline gap={2}> <Button disabled tone="secondary" variant="outline"> Export </Button> <Button aria-describedby={hintId} disabled focusableWhenDisabled> Submit for approval </Button> </Inline> <Text id={hintId} size="sm" tone="muted"> Add at least one line item before submitting. </Text> </Stack> );}Links
ButtonLink puts the same surface on an anchor. Use it for navigation and Button for an action. A disabled link drops its href, so a middle click or a modified click cannot follow it, and stays focusable with role="link" and aria-disabled.
import { ButtonLink } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';export default function ButtonLinkExample() { return ( <Inline gap={2}> <ButtonLink end={<Glyph name="chevron-right" />} href="/invoices/INV-2041"> View invoice </ButtonLink> <ButtonLink disabled href="/statements/2026-09.pdf" tone="secondary" variant="outline"> Download statement </ButtonLink> </Inline> );}Full width
fullWidth fills the inline size of the container, for the primary actions of a narrow panel, a checkout or a sign-in form.
import { Button } from '@slotted/react/button';import { Stack } from '@slotted/react/stack';export default function ButtonFullWidth() { return ( <Stack gap={2}> <Button fullWidth>Pay $1,240.00</Button> <Button fullWidth tone="secondary" variant="outline"> Pay by bank transfer </Button> </Stack> );}Toggle buttons
ToggleButton holds an on or off state in aria-pressed, under a label that never changes with the state. Pass pressed and handle the change request to own the state, or pass defaultPressed and let the button own it. IconButton takes the same two props and becomes a toggle only when one of them is present.
import { useState } from 'react';import { IconButton, ToggleButton } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function ButtonToggle() { const [autoRefresh, setAutoRefresh] = useState(true); return ( <Stack gap={2}> <Inline align="center" gap={2}> <ToggleButton onPressedChange={(pressed) => setAutoRefresh(pressed)} pressed={autoRefresh}> Auto-refresh </ToggleButton> <ToggleButton defaultPressed start={<Glyph name="pin" />}> Pin to dashboard </ToggleButton> <IconButton aria-label="Mark as priority" defaultPressed={false}> <Glyph name="star" /> </IconButton> </Inline> <Text size="sm" tone="muted"> {autoRefresh ? 'Balances refresh every 30 seconds.' : 'Balances refresh on demand.'} </Text> </Stack> );}Groups
ButtonGroup joins related actions into one shape with role="group". Its tone, variant and size become the defaults of every button inside it, and a button that sets its own value keeps it. Every button keeps its own place in the tab sequence.
import { Button, IconButton } from '@slotted/react/button';import { ButtonGroup } from '@slotted/react/button-group';import { Glyph } from '@slotted/react/icon';export default function ButtonGroupExample() { return ( <ButtonGroup aria-label="Invoice actions" tone="secondary" variant="outline"> <Button>Edit</Button> <Button>Duplicate</Button> <Button>Send</Button> <IconButton aria-label="More invoice actions"> <Glyph name="ellipsis" /> </IconButton> </ButtonGroup> );}Toolbars
Inside a Toolbar, buttons drop in unwrapped and the bar becomes one tab stop with arrow-key movement between them. A disabled action stays in that sequence with focusableWhenDisabled, so the reason it is unavailable can be reached from the keyboard.
import { useId } from 'react';import { Button, IconButton } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Toolbar, ToolbarSeparator, ToolbarSpacer } from '@slotted/react/toolbar';import { Text } from '@slotted/react/typography';export default function ButtonToolbar() { const reasonId = useId(); return ( <Toolbar aria-label="Order SO-1187"> <Button start={<Glyph name="file-text" />} tone="secondary" variant="ghost"> Packing slip </Button> <Button tone="secondary" variant="ghost"> Duplicate </Button> <ToolbarSeparator /> <IconButton aria-label="Copy order number"> <Glyph name="copy" /> </IconButton> <IconButton aria-describedby={reasonId} aria-label="Delete order" disabled focusableWhenDisabled tone="danger" > <Glyph name="trash" /> </IconButton> <ToolbarSpacer /> <Text id={reasonId} size="sm" tone="muted"> Shipped orders cannot be deleted. </Text> </Toolbar> );}Application defaults
Set size, tone and variant once for a region instead of on every button: ButtonDefaultsProvider in React, provideButtonDefaults in Angular. A button that sets an axis itself overrides the default, and an axis the defaults leave unset keeps each member’s own.
import { Button, ButtonDefaultsProvider } from '@slotted/react/button';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';export default function ButtonDefaults() { return ( <ButtonDefaultsProvider size="sm" tone="secondary" variant="outline"> <Inline gap={2}> <Button start={<Glyph name="funnel" />}>Filter</Button> <Button>Columns</Button> <Button>Export</Button> <Button start={<Glyph name="plus" />} tone="accent" variant="solid"> New order </Button> </Inline> </ButtonDefaultsProvider> );}Destructive confirmation
A destructive action opens an AlertDialog, whose cancel and confirm controls render as buttons. Focus starts on the cancel action, an outside press does not close the dialog, and the confirm action repeats the danger tone of the trigger. After the deletion, focusableWhenDisabled keeps the trigger in the tab sequence while it announces aria-disabled.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogIcon, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger,} from '@slotted/react/dialog';import { Glyph } from '@slotted/react/icon';import { Inline } from '@slotted/react/inline';import { Text } from '@slotted/react/typography';export default function ButtonConfirmDelete() { const [open, setOpen] = useState(false); const [deleted, setDeleted] = useState(false); return ( <Inline align="center" gap={2}> <AlertDialog onOpenChange={setOpen} open={open}> <DialogTrigger render={(props) => ( <Button {...props} disabled={deleted} focusableWhenDisabled start={<Glyph name="trash" />} tone="danger" variant="outline" > Delete supplier </Button> )} /> <DialogContent> <DialogHeader> <AlertDialogIcon /> <DialogTitle>Delete Northwind Traders?</DialogTitle> <DialogDescription> The supplier and its 18 open purchase orders are removed for everyone. This cannot be undone. </DialogDescription> </DialogHeader> <DialogFooter> <AlertDialogCancel render={(props) => ( <Button {...props} tone="secondary" variant="outline"> Keep supplier </Button> )} /> <AlertDialogAction onClick={() => setDeleted(true)} render={(props) => ( <Button {...props} tone="danger"> Delete supplier </Button> )} /> </DialogFooter> </DialogContent> </AlertDialog> {deleted ? ( <> <Text size="sm" tone="muted"> Northwind Traders was deleted. </Text> <Button onClick={() => setDeleted(false)} size="sm" tone="secondary" variant="ghost"> Undo </Button> </> ) : null} </Inline> );}Accessibility
Button
- Button renders a native button element, so Space, Enter, focus and the disabled state come from the platform. The visible label supplies the accessible name.
- While loading, the indicator is a progress bar named by messages.loading, and the button announces aria-disabled while it keeps focus. React Aria’s pending button and Primer’s loading button use the same pattern. aria-busy is not set: screen readers do not announce it reliably on a button, and one mechanism already carries the state.
- Where motion is allowed, the indicator is not drawn: once loadingDelay has passed, a band in the button’s own ink sweeps behind the label and the icon, which stay visible. With reduced motion or forced colors, the indicator is a ring drawn in the start or end icon’s box; a button with neither draws it over the label, which drops to zero opacity but stays in the accessibility tree and in the layout, so the accessible name survives the wait and the button keeps its size.
- loading refuses activation in the capture phase, before any click handler you attach, so a submit button cannot submit its form twice.
- focusableWhenDisabled keeps a disabled button reachable. Use it when the button has a tooltip or an explanation a keyboard user needs, such as inside a toolbar. A reachable disabled button uses muted text on the subtle neutral background, at a contrast of 4.5:1 or more; a natively disabled button keeps the disabled grey.
- An icon in start or end repeats the label, so mark it aria-hidden. Glyph sets aria-hidden itself.
- type defaults to button. Set submit only for a button that submits its form.
ButtonLink
- ButtonLink renders an anchor, so it is announced as a link and activates on Enter. Space does not activate it, as it does not activate any link.
- Use ButtonLink for navigation only. An action without a destination is a Button.
- A disabled ButtonLink renders no href. An anchor that kept its destination and only blocked click would still navigate on a middle click or a modified click.
- A disabled ButtonLink stays in the tab sequence with role="link" and aria-disabled, so a keyboard user can discover that it is unavailable.
- The render function receives every root prop, including the accessible name and the data attributes, and must pass all of them to the element it renders.
IconButton
- The type requires an accessible name: pass aria-label or aria-labelledby. An icon supplies no text the name could be computed from.
- aria-pressed is rendered only when pressed or defaultPressed is passed, so a plain icon button does not announce a toggle state it does not have.
- Keep the name the same in both pressed states. The APG toggle button pattern announces the state beside an unchanging label.
- A pressed icon button uses the selected colors of the theme — accent text on the accent selection background, inside the accent edge — whatever its tone and variant. On hover it uses the hover step of that background, not the neutral hover of an unpressed button.
- The control is as wide as it is tall, at the control height, and never smaller than the WCAG 2.2 minimum target of 24 by 24 CSS pixels at any density.
- Add a tooltip when the icon alone does not say what the action does. The accessible name does not replace a visible label.
iconButtonLink
- IconButtonLink renders an anchor, so it is announced as a link and activates on Enter. Use it for an icon-only control that navigates, such as the previous and next record; an icon-only action is an IconButton.
- The type requires an accessible name: pass aria-label or aria-labelledby. An icon supplies no text the name could be computed from.
- A disabled IconButtonLink renders no href and stays in the tab sequence with role="link" and aria-disabled.
- The render function receives every root prop, including the accessible name and the data attributes, and must pass all of them to the element it renders.
ToggleButton
- ToggleButton renders a native button with aria-pressed, so it is announced as a toggle button and activates on Space and Enter.
- Keep the label the same in both states: "Mute" stays "Mute" and the state is announced beside it. When the label has to change, use a Button.
- The change request carries a reason. A native button fires the same click for a pointer, Space and Enter; the reason is pointer when the click reports a click count and keyboard when it reports none.
- Calling preventDefault in onClick refuses the activation, and the pressed state does not change.
- Use Checkbox, not ToggleButton, for a value a form submits.
- A toggle that saves to a server can set loading while the request runs. Activation is refused during the wait, so the button keeps the state it had until loading ends.
API
Button
Props
toneaccent | secondary | neutral | info | success | warning | dangerDefaultaccent- The semantic color: accent for the primary action, secondary for a neutral one, neutral for a primary action drawn in ink where the accent is kept for data, and success, warning or danger for what the action does.
variantsolid | outline | ghostDefaultsolid- How the tone is painted: solid, outline or ghost.
sizesm | md | lgDefaultmd- The step of the control scale. Each step reads the --slotted-control-* tokens, so the density of the theme sets the height.
startReactNode- Content before the label, such as an icon. It mirrors in a right-to-left document.
endReactNode- Content after the label, such as an icon. It mirrors in a right-to-left document.
fullWidthbooleanDefaultfalse- Fills the inline size of the container.
flush'start' | 'end' | 'both'- Stands the label on the edge of the text around it: the button is pulled out by its own inset on the stated side, and the hover ground, the target and the focus ring extend past that edge. For a ghost button as the first line of a stacked cell. It has no effect on an inline button, which has no inset.
inlinebooleanDefaultfalse- A word of the surrounding text, for an action inside a sentence or a dense cell: no box in any variant, the font, line height and baseline of the text around it, underlined in the tone. A stated size sets the step of the text scale (--slotted-font-size-sm, -md, -lg); without one the font is the one around it, whatever a provider states. A row of small text keeps its height.
justifycenter | betweenDefaultcenter- Where the content sits along the inline axis: center keeps the label and end together in the middle; between sets the label at the start and end at the inline end, as a field trigger reads, with start beside the label. It mirrors in a right-to-left document.
widestreadonly string[]- Every text the label can take, for a label that changes under the pointer (the month of a stepper): the control reserves the width of its whole content with the widest of them, in tabular figures, and centers what is visible. A start that renders nothing keeps its room in the reservation and takes none beside the label, so a mark comes and goes at one width; --slotted-button-widest-start states the width reserved for a start narrower than an icon. The entries stay out of the accessible name; no effect under fullWidth.
disabledbooleanDefaultfalse- Refuses the action and marks the control unavailable. On its own, it sets the native disabled attribute, which also removes the control from the tab sequence.
focusableWhenDisabledbooleanDefaultfalse- Keeps a disabled control in the tab sequence: aria-disabled replaces the native attribute, and activation is still refused.
loadingbooleanDefaultfalse- Refuses activation, keeps focus, and shows a progress indicator named by messages.loading.
loadingDelaynumberDefault0- Milliseconds before the indicator appears. Activation is refused from the start of the wait.
messagesPartial<ButtonMessages>- Overrides for the strings of the active locale, key by key. loading names the progress indicator.
render(rootProps) => ReactElement- Renders the root through another element. The function receives every root prop and must pass all of them on.
typebutton | submit | resetDefaultbutton- The native button type. Set submit only for a button that submits its form.
Composition
ButtonDefaultsProvider{ size?, tone?, variant?, children }- Sets the default size, tone and variant of every button inside it, ButtonLink, IconButton and ToggleButton included. An explicit prop wins, and an axis left unset keeps each member’s own default.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | button, or the element render returns | Yes | The control. Carries data-ui="button", data-tone, data-variant and data-size. It also carries data-justify, and data-full-width, data-flush, data-inline, data-disabled and data-loading when they apply. |
start | span | No | Wraps the start content. Rendered only when start is passed. While loading, it holds the indicator. |
label | span | Yes | Wraps the children. Always rendered, because the accessible name is computed from it. With reduced motion or forced colors, a loading button with no icon fades it in place, and it keeps its size. |
end | span | No | Wraps the end content. Rendered only when end is passed. While loading, it holds the indicator when there is no start content. |
indicator | span with role="progressbar" | No | The loading indicator. Carries data-ui="spinner", is named by messages.loading, and has no value, so it reads as indeterminate. Rendered in the start box, else in the end box, else centerd over the label, once loadingDelay has passed. |
ButtonLink
Props
hrefstringDefault required without render- The destination. A disabled ButtonLink does not render it.
render(rootProps) => ReactElement- Renders the root through a router’s link component. The function receives every root prop and must pass all of them on.
toneaccent | secondary | neutral | info | success | warning | dangerDefaultaccent- The semantic color: accent for the primary action, secondary for a neutral one, neutral for a primary action drawn in ink where the accent is kept for data, and success, warning or danger for what the action does.
variantsolid | outline | ghostDefaultsolid- How the tone is painted: solid, outline or ghost.
sizesm | md | lgDefaultmd- The step of the control scale. Each step reads the --slotted-control-* tokens, so the density of the theme sets the height.
startReactNode- Content before the label, such as an icon. It mirrors in a right-to-left document.
endReactNode- Content after the label, such as an icon. It mirrors in a right-to-left document.
fullWidthbooleanDefaultfalse- Fills the inline size of the container.
justifycenter | betweenDefaultcenter- Where the content sits along the inline axis: center keeps the label and end together in the middle; between sets the label at the start and end at the inline end, as a field trigger reads, with start beside the label. It mirrors in a right-to-left document.
widestreadonly string[]- Every text the label can take, for a label that changes under the pointer (the month of a stepper): the control reserves the width of its whole content with the widest of them, in tabular figures, and centers what is visible. A start that renders nothing keeps its room in the reservation and takes none beside the label, so a mark comes and goes at one width; --slotted-button-widest-start states the width reserved for a start narrower than an icon. The entries stay out of the accessible name; no effect under fullWidth.
disabledbooleanDefaultfalse- Removes the href and refuses activation. The link stays focusable with role="link" and aria-disabled.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | a, or the element render returns | Yes | The control. Carries data-ui="button", data-tone, data-variant and data-size. It also carries data-justify, and data-full-width and data-disabled when they apply. |
start | span | No | Wraps the start content. Rendered only when start is passed. |
label | span | Yes | Wraps the children. Always rendered, because the accessible name is computed from it. |
end | span | No | Wraps the end content. Rendered only when end is passed. |
IconButton
Props
aria-label | aria-labelledbystringDefaultrequired- The accessible name. Required, because an icon supplies no text. When both are present, aria-labelledby names the button.
toneaccent | secondary | neutral | info | success | warning | dangerDefaultsecondary- The semantic color: accent for the primary action, secondary for a neutral one, neutral for a primary action drawn in ink where the accent is kept for data, and success, warning or danger for what the action does.
variantsolid | outline | ghostDefaultghost- How the tone is painted: solid, outline or ghost.
sizesm | md | lgDefaultmd- The step of the control scale. Each step reads the --slotted-control-* tokens, so the density of the theme sets the height.
shapesquare | circleDefaultsquare- The corners of the control: square keeps the radius of the control scale, circle rounds it fully. Both are as wide as they are tall.
inlinebooleanDefaultfalse- One line of the surrounding text tall, for a help trigger inside a sentence or a term: the line does not grow, and a 24px target stays around it. The icon is drawn from the capital height of the text, centered on the capital beside it, and the size of the Icon has no effect; in a flex row, align-items: baseline puts it on the first line. In ghost it draws no ground under the pointer; in the secondary tone it is muted at rest and takes the text color on hover, on keyboard focus and while its tooltip or popover is open.
disabledbooleanDefaultfalse- Refuses the action and marks the control unavailable. On its own, it sets the native disabled attribute, which also removes the control from the tab sequence.
focusableWhenDisabledbooleanDefaultfalse- Keeps a disabled control in the tab sequence: aria-disabled replaces the native attribute, and activation is still refused.
loadingbooleanDefaultfalse- Refuses activation, keeps focus, and shows a progress indicator named by messages.loading.
loadingDelaynumberDefault0- Milliseconds before the indicator appears. Activation is refused from the start of the wait.
messagesPartial<ButtonMessages>- Overrides for the strings of the active locale, key by key. loading names the progress indicator.
render(rootProps) => ReactElement- Renders the root through another element. The function receives every root prop and must pass all of them on.
pressedboolean- The pressed state, controlled. Passing it makes the button a toggle whose value you own.
defaultPressedboolean- The initial pressed state when the button owns it, read once. Passing it makes the button a toggle.
onPressedChange(pressed, request) => void- Called with the requested value and the request: value, previous value, reason (pointer or keyboard), event and cancel().
typebutton | submit | resetDefaultbutton- The native button type. Set submit only for a button that submits its form.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | button, or the element render returns | Yes | The control. Carries data-ui="button", data-tone, data-variant and data-size. It also carries data-shape, and data-inline, data-disabled, data-loading and data-pressed when they apply. |
icon | span | Yes | Wraps the children. While loading, it holds the indicator drawn over the icon, so the control keeps its size. |
indicator | span with role="progressbar" | No | The loading indicator. Carries data-ui="spinner", is named by messages.loading, and has no value, so it reads as indeterminate. Rendered inside the icon box once loadingDelay has passed. |
iconButtonLink
Props
aria-label | aria-labelledbystringDefaultrequired- The accessible name. Required, because an icon supplies no text. When both are present, aria-labelledby names the link.
hrefstringDefault required without render- The destination. A disabled IconButtonLink does not render it.
render(rootProps) => ReactElement- Renders the root through a router’s link component. The function receives anchor props — every root prop — and must pass all of them on.
toneaccent | secondary | neutral | info | success | warning | dangerDefaultsecondary- The semantic color: accent for the primary action, secondary for a neutral one, neutral for a primary action drawn in ink where the accent is kept for data, and success, warning or danger for what the action does.
variantsolid | outline | ghostDefaultghost- How the tone is painted: solid, outline or ghost.
sizesm | md | lgDefaultmd- The step of the control scale. Each step reads the --slotted-control-* tokens, so the density of the theme sets the height.
shapesquare | circleDefaultsquare- The corners of the control: square keeps the radius of the control scale, circle rounds it fully. Both are as wide as they are tall.
disabledbooleanDefaultfalse- Removes the href and refuses activation. The link stays focusable with role="link" and aria-disabled.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | a, or the element render returns | Yes | The control. Carries data-ui="button", data-tone, data-variant and data-size. It also carries data-shape, and data-disabled when it applies. |
icon | span | Yes | Wraps the children. |
ToggleButton
Props
toneaccent | secondary | neutral | info | success | warning | dangerDefaultsecondary- The semantic color: accent for the primary action, secondary for a neutral one, neutral for a primary action drawn in ink where the accent is kept for data, and success, warning or danger for what the action does.
variantsolid | outline | ghostDefaultoutline- How the tone is painted: solid, outline or ghost.
sizesm | md | lgDefaultmd- The step of the control scale. Each step reads the --slotted-control-* tokens, so the density of the theme sets the height.
startReactNode- Content before the label, such as an icon. It mirrors in a right-to-left document.
endReactNode- Content after the label, such as an icon. It mirrors in a right-to-left document.
fullWidthbooleanDefaultfalse- Fills the inline size of the container.
justifycenter | betweenDefaultcenter- Where the content sits along the inline axis: center keeps the label and end together in the middle; between sets the label at the start and end at the inline end, as a field trigger reads, with start beside the label. It mirrors in a right-to-left document.
widestreadonly string[]- Every text the label can take, for a label that changes under the pointer (the month of a stepper): the control reserves the width of its whole content with the widest of them, in tabular figures, and centers what is visible. A start that renders nothing keeps its room in the reservation and takes none beside the label, so a mark comes and goes at one width; --slotted-button-widest-start states the width reserved for a start narrower than an icon. The entries stay out of the accessible name; no effect under fullWidth.
disabledbooleanDefaultfalse- Refuses the action and marks the control unavailable. On its own, it sets the native disabled attribute, which also removes the control from the tab sequence.
focusableWhenDisabledbooleanDefaultfalse- Keeps a disabled control in the tab sequence: aria-disabled replaces the native attribute, and activation is still refused.
loadingbooleanDefaultfalse- Refuses activation, keeps focus, and shows a progress indicator named by messages.loading.
loadingDelaynumberDefault0- Milliseconds before the indicator appears. Activation is refused from the start of the wait.
messagesPartial<ButtonMessages>- Overrides for the strings of the active locale, key by key. loading names the progress indicator.
render(rootProps) => ReactElement- Renders the root through another element. The function receives every root prop and must pass all of them on.
pressedboolean- The pressed state, controlled. Passing it makes you the owner of the value.
defaultPressedbooleanDefaultfalse- The initial pressed state when the button owns it, read once.
onPressedChange(pressed, request) => void- Called with the requested value and the request: value, previous value, reason (pointer or keyboard), event and cancel().
typebutton | submit | resetDefaultbutton- The native button type. Set submit only for a button that submits its form.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | button, or the element render returns | Yes | The control. Carries data-ui="button", data-tone, data-variant and data-size. It also carries data-justify, and data-full-width, data-disabled, data-loading and data-pressed when they apply. |
start | span | No | Wraps the start content. Rendered only when start is passed. While loading, it holds the indicator. |
label | span | Yes | Wraps the children. Always rendered, because the accessible name is computed from it. With reduced motion or forced colors, a loading button with no icon fades it in place, and it keeps its size. |
end | span | No | Wraps the end content. Rendered only when end is passed. While loading, it holds the indicator when there is no start content. |
indicator | span with role="progressbar" | No | The loading indicator. Carries data-ui="spinner", is named by messages.loading, and has no value, so it reads as indeterminate. Rendered in the start box, else in the end box, else centerd over the label, once loadingDelay has passed. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every button inside it.
Button tokens
| Token | Default |
|---|---|
--slotted-button-widest-start | var(--_icon-size) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-border-subtle | Set per scheme by the theme |
--slotted-border-width-thin | 1px |
--slotted-control-border-color | Set per scheme by the theme |
--slotted-control-border-width | var(--slotted-border-width-thin) |
--slotted-control-font-family | var(--slotted-font-family-sans) |
--slotted-control-font-size-lg | comfortable 14px · compact 13px · dense 12px |
--slotted-control-font-size-md | comfortable 13px · compact 12px · dense 12px |
--slotted-control-font-size-sm | comfortable 12px · compact 12px · dense 12px |
--slotted-control-font-weight | var(--slotted-font-weight-semibold) |
--slotted-control-gap-lg | comfortable 8px · compact 6px · dense 6px |
--slotted-control-gap-md | comfortable 8px · compact 6px · dense 4px |
--slotted-control-gap-sm | comfortable 6px · compact 4px · dense 4px |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-control-icon-size-lg | comfortable 18px · compact 16px · dense 14px |
--slotted-control-icon-size-md | comfortable 16px · compact 14px · dense 13px |
--slotted-control-icon-size-sm | comfortable 14px · compact 13px · dense 12px |
--slotted-control-letter-spacing | 0 |
--slotted-control-line-height | 1 |
--slotted-control-padding-inline-lg | comfortable 16px · compact 12px · dense 10px |
--slotted-control-padding-inline-md | comfortable 13px · compact 10px · dense 8px |
--slotted-control-padding-inline-sm | comfortable 10px · compact 8px · dense 6px |
--slotted-control-radius | var(--slotted-radius-sm) |
--slotted-control-shadow | Set per scheme by the theme |
--slotted-control-transition-duration | var(--slotted-duration-short) |
--slotted-control-transition-easing | var(--slotted-easing-standard) |
--slotted-disabled-background | Set per scheme by the theme |
--slotted-disabled-border | Set per scheme by the theme |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-duration-instant | 1ms |
--slotted-duration-loop | 1.1s |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-offset | var(--slotted-border-width-thick) |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-font-size-lg | 1rem |
--slotted-font-size-md | 0.875rem |
--slotted-font-size-sm | 0.8125rem |
--slotted-line-height-sm | 1.45 |
--slotted-radius-full | 9999px |
--slotted-radius-sm | 4px |
--slotted-space-2 | 0.25rem |
--slotted-target-min | 24px |
--slotted-text | Set per scheme by the theme |
--slotted-text-box-edge | cap alphabetic |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-accent-border | Set per scheme by the theme |
--slotted-tone-accent-on-solid | Set per scheme by the theme |
--slotted-tone-accent-solid | Set per scheme by the theme |
--slotted-tone-accent-solid-active | Set per scheme by the theme |
--slotted-tone-accent-solid-hover | Set per scheme by the theme |
--slotted-tone-accent-subtle-active | Set per scheme by the theme |
--slotted-tone-accent-subtle-hover | Set per scheme by the theme |
--slotted-tone-accent-text | Set per scheme by the theme |
--slotted-tone-danger-border | Set per scheme by the theme |
--slotted-tone-danger-on-solid | Set per scheme by the theme |
--slotted-tone-danger-solid | Set per scheme by the theme |
--slotted-tone-danger-solid-active | Set per scheme by the theme |
--slotted-tone-danger-solid-hover | Set per scheme by the theme |
--slotted-tone-danger-text | Set per scheme by the theme |
--slotted-tone-info-on-solid | Set per scheme by the theme |
--slotted-tone-info-solid | Set per scheme by the theme |
--slotted-tone-info-solid-active | Set per scheme by the theme |
--slotted-tone-info-solid-hover | Set per scheme by the theme |
--slotted-tone-info-text | Set per scheme by the theme |
--slotted-tone-neutral-on-solid | Set per scheme by the theme |
--slotted-tone-neutral-solid | Set per scheme by the theme |
--slotted-tone-neutral-solid-active | Set per scheme by the theme |
--slotted-tone-neutral-solid-hover | Set per scheme by the theme |
--slotted-tone-neutral-text | Set per scheme by the theme |
--slotted-tone-secondary-on-solid | Set per scheme by the theme |
--slotted-tone-secondary-solid | Set per scheme by the theme |
--slotted-tone-secondary-solid-active | Set per scheme by the theme |
--slotted-tone-secondary-solid-hover | Set per scheme by the theme |
--slotted-tone-secondary-subtle-active | Set per scheme by the theme |
--slotted-tone-secondary-subtle-hover | Set per scheme by the theme |
--slotted-tone-secondary-text | Set per scheme by the theme |
--slotted-tone-success-on-solid | Set per scheme by the theme |
--slotted-tone-success-solid | Set per scheme by the theme |
--slotted-tone-success-solid-active | Set per scheme by the theme |
--slotted-tone-success-solid-hover | Set per scheme by the theme |
--slotted-tone-success-text | Set per scheme by the theme |
--slotted-tone-warning-on-solid | Set per scheme by the theme |
--slotted-tone-warning-solid | Set per scheme by the theme |
--slotted-tone-warning-solid-active | Set per scheme by the theme |
--slotted-tone-warning-solid-hover | Set per scheme by the theme |
--slotted-tone-warning-text | Set per scheme by the theme |