Button
One control for actions, links, icon-only triggers, toggles, async outcomes, clipboard copy, and split menus.
import { Button } from '@uthereal/ui/button'Button playground
Overview
Button renders a native <button> that reports a named action to your application, or a native <a> when href is set. Every button mode shares one schema, so React apps, agent compositions, and live agent edits use the same arguments.
Use Button for a single action or a primary action with related menu items. Use ButtonGroup for two or more peer actions, and DropdownMenu for a menu without a primary action.
| Mode | Trigger prop(s) | Behavior |
|---|---|---|
| Standard | label, action | Calls onClick and onAction. Supports loading with preserved width. |
| Link | href | Renders an <a> for http(s), mailto, and relative URLs. Cannot combine with action. |
| Icon-only | hideLabel, icon | Renders a square or circle icon trigger. Keeps label as the accessible name and enables tooltip by default. |
| Toggle | defaultPressed or pressed | Tracks pressed state, sets aria-pressed, and applies a pressed tint. Plain buttons never set aria-pressed. |
| Action outcome | status or promise return, optional showArrow | Morphs through pendingLabel, successLabel, and errorLabel, then resets after resetAfterMs (2400ms default). |
| Copy | copyValue | Writes text (up to 200,000 characters) to the clipboard, confirms with a drawn check and "Copied", and resets after 1900ms. |
| Split | menuItems | Joins the main action to a chevron menu with actions, links, checkboxes, radios, separators, and submenus. |
Usage
'use client'
import { Button } from '@uthereal/ui/button'
export function SaveBar({ saving }: { saving: boolean }) {
return (
<Button
label="Save changes"
icon="check"
action="save_changes"
loading={saving}
loadingLabel="Saving"
onAction={(action) => console.log(action)}
/>
)
}onClick runs before onAction. Your application owns side effects and implements the named action.
Examples
Use <SchemaPlayground /> above to inspect variant, tone, size, shape, icon, and endIcon. The examples below show distinct behavioral modes.
Icon-only and tooltips
hideLabel renders only the icon and keeps label as the accessible name. tooltip defaults to true when hideLabel is enabled, and shortcut appends a display-only key hint such as "⌘K". Disabled buttons never open a tooltip.
Loading
loading replaces the content with a ring spinner while preserving the button width. The button stays focusable, sets aria-busy, blocks activation and form submission, and announces loadingLabel politely.
Action outcomes
Return a promise from onClick or onAction to drive the outcome lifecycle automatically, or control status directly with status and onStatusChange. Set showArrow to show a trailing arrow at rest that exits forward while a spinner or drawn check enters. Set resetAfterMs to 0 to keep the settled state.
<Button label="Save changes" showArrow onClick={() => saveChanges()} />Copy
copyValue copies text on activation, defaults icon to "copy" and successLabel to "Copied", and confirms with a drawn check before resetting after 1900ms. onCopyResult reports whether the clipboard write succeeded. copyValue cannot combine with href, menuItems, or showArrow.
<Button label="Copy link" copyValue="https://uthereal.ai" icon="copy" />Split actions
menuItems adds a chevron segment that opens a DropdownMenu beside the main button. Menu items require stable unique IDs, and checkbox and radio selections persist in checked state. menuLabel names the chevron button ("{label} more actions" by default).
<Button
label="Export"
icon="download"
action="export_pdf"
menuItems={[
{ kind: 'action', id: 'csv', label: 'Export as CSV', action: 'export_csv' },
{ kind: 'separator', id: 'sep' },
{ kind: 'link', id: 'docs', label: 'Export guide', href: '/docs/export' },
]}
/>Toggle and links
Pass defaultPressed for an uncontrolled toggle, or pressed with onPressedChange for a controlled toggle. Pass href to render a link; target="_blank" adds rel="noopener noreferrer" unless you supply rel.
<Button
label="Mute"
icon="volume-off"
defaultPressed={false}
onPressedChange={(pressed) => console.log(pressed)}
/>
<Button label="Read the guide" href="/docs/agents" variant="link" />API reference
Serializable schema arguments and defaults come directly from buttonConfigSchema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Button" | Visible text and accessible name. Name the action and its object, e.g. "Save changes". |
variant | solid | soft | outline | ghost | linkDefault: "solid" | Fill treatment: solid for the main action, soft, outline or ghost for others, link for text-like actions. |
tone | neutral | accent | dangerDefault: "neutral" | Color role. neutral is ink whatever the accent (Arc's primary button), accent follows the theme accent, and danger marks destructive actions. |
size | xs | sm | md | lgDefault: "md" | Height: 32, 36, 44, or 50 pixels, with 14px text at every size. Matches the dropdown trigger of the same size. |
shape | default | pill | square | circleDefault: "default" | Corner treatment. Default from the recipe; pill is fully rounded; square and circle are controlHeight boxes that suit icon-only buttons. |
icon | IconName— | Decorative icon before the label. Any name from the Icons page. |
endIcon | IconName— | Decorative icon after the label, from the same names. Directional icons mirror in RTL. |
hideLabel | booleanDefault: false | Icon-only: show only the icon (needs one); the label stays the accessible name, and the button becomes a controlHeight square. |
tooltip | booleanDefault: false | While icon-only (or with a shortcut), show the label in a tooltip on hover and keyboard focus, so sighted users can read what the button does. Not shown while disabled. |
shortcut | string— | A keyboard shortcut shown in the tooltip after the label, e.g. "⌘K". Display only: the application binds the key. |
tooltipPlacement | PlacementDefault: "top" | Preferred side of the tooltip. Collision detection flips it when there is no room. |
loading | booleanDefault: false | Show a spinner in place of the content. The width is kept, the button stays focusable, and activation is blocked. |
loadingLabel | stringDefault: "Loading" | Announced to assistive technology when loading starts, e.g. "Saving". |
status | idle | pending | success | error— | Outcome of the action: pending shows pendingLabel, success shows successLabel, error shows errorLabel, and each returns to idle after resetAfterMs unless the host drives the status itself. |
pendingLabel | stringDefault: "Saving" | Shown while the outcome is pending, e.g. "Saving". |
successLabel | stringDefault: "Saved" | Shown when the outcome is success. "Saved", or "Copied" when copyValue is set. |
errorLabel | stringDefault: "Failed" | Shown when the outcome fails, e.g. "Failed". |
showArrow | booleanDefault: false | A trailing arrow at rest that leaves forward on pending and success while a drawn check enters (Arc action-button). |
resetAfterMs | integer— | How long a success or error result shows before returning to idle, ms. 0 keeps it. Unset: 2400, or 1900 for a copy. |
copyValue | string— | Copy this text to the clipboard on activation, confirming with a drawn check. Up to 200,000 characters. Cannot combine with href, menuItems or showArrow. |
defaultPressed | boolean— | Initial pressed state (toggle mode). Edits do not reset a mounted instance; in compositions the stored state wins. |
menuItems | MenuItem[]— | The menu of the split outcome: dropdown menu item kinds (action, link, checkbox, radio, separator, submenu), with stable unique IDs. Up to 200 items and five submenu levels. |
menuLabel | stringDefault: "{label} more actions" | Accessible name of the menu button, which shows only a chevron. {label} is the main label; the default "{label} more actions" is Arc's name. |
menuPlacement | PlacementDefault: "bottom-end" | Preferred side and alignment of the menu. Collision detection flips it when there is no room. |
fullWidth | booleanDefault: false | Stretch to the width of the container. |
type | button | submit | resetDefault: "button" | Native type inside a form. Ignored for links. |
action | string— | Name of an action registered by your application. Sent to onAction when the button is activated. |
href | string— | Navigate to this URL instead of sending an action. Renders a link; http(s), mailto and relative URLs only. |
disabled | booleanDefault: false | Unavailable and removed from the tab order. A disabled link loses its URL. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | ButtonTheme— | Color mode, accent, and semantic tokens. The attached menu follows the mode and accent. |
motion | none | subtle | expressiveDefault: "subtle" | Press, swap and menu animation preset. System reduced-motion preferences take precedence. |
motionOptions | ButtonMotionOptions— | Press scale (omitted, it follows the width), and label swap duration (ms) and travel (px). |
dir | ltr | rtl— | Reading direction. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
onAction(action, itemId) | Handles the main action or a split menu item action. Returning a promise drives status when uncontrolled. |
onClick(event) | Native click handler; runs before onAction, never while loading or pending. A returned promise drives status. |
status, onStatusChange | Controlled outcome status (idle, pending, success, error) and change callback. |
onCopyResult(copied) | Called after each copy attempt with whether the clipboard accepted the text. |
pressed, onPressedChange | Controlled toggle state and change callback; use defaultPressed for uncontrolled toggles. |
open, onOpenChange | Controlled split menu open state and change callback. |
checked, onCheckedChange | Controlled checkbox and radio state for split menu items, keyed by item ID. |
portalContainer | Mount container for the split menu portal. |
renderIcon(name, context) | Replaces named icons (including the success check) with custom decorative icons. |
preset | Component defaults overridden by explicit instance props. |
tokens | --ui-* CSS variables applied after the typed theme on all segments and attached popups. |
ref | Ref to the rendered <button>, <a>, or split <div> group. |
className, style | Added to the root element; style wins over motion and theme tokens. |
| Native attributes | Forwarded attributes including id, aria-*, title, form, name, target, and rel. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Moves focus to the button with a focus ring. |
Enter, Space | Activates buttons; links activate with Enter. |
Arrow Down | Opens the menu from a split button chevron. |
Write label as a verb with an object ("Save changes", not "Submit"). Icon-only buttons hide the label visually and expose it through the accessible name and tooltip. Disabled buttons leave the tab order, and disabled links drop href. Loading and pending states keep focus, set aria-busy and aria-disabled, and announce status updates from a polite role="status" region outside the button. Directional icons and arrow motion mirror in RTL (dir="rtl"). Under forced-colors: active, solid and pressed buttons use Highlight and HighlightText, and focus outlines remain visible.
Motion and theming
Pressing scales the button by width (0.96 up to 48px, 0.985 above 220px, 0.97 between) and releases on a spring. Set motionOptions.pressScale to override the factor, or 1 to disable press scale. Plain label changes rise from a soft blur, outcome and split labels morph glyph by glyph with spring width transitions, and success draws a check stroke. motion="none" removes all transitions and stops spinners. prefers-reduced-motion: reduce removes travel and press scale, keeps a 120ms opacity crossfade, and stops spinners after one turn.
theme accepts mode, accent, and tokens from the core and control groups plus toneForeground, tintStrength, shadowResting, borderSubtle, and success. Attached tooltips and split menus inherit mode, accent, and tokens. UtherealProvider supplies application-wide defaults.
Composition
In agent compositions, Button is a leaf. Register every action (main button and menu action items) on the host; handlers receive { componentId, itemId }. Toggle state persists at /menus/instance-<id>/pressed only when defaultPressed is set, so plain buttons never receive aria-pressed. Split checkbox and radio state persists at /menus/instance-<id>/checked. See Building with agents.
{
"type": "Button",
"props": {
"label": "Export report",
"icon": "download",
"action": "export_report",
"menuItems": [
{
"kind": "action",
"id": "csv",
"label": "Export as CSV",
"action": "export_csv"
}
]
},
"children": []
}