UI

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

Loading interactive preview…

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.

ModeTrigger prop(s)Behavior
Standardlabel, actionCalls onClick and onAction. Supports loading with preserved width.
LinkhrefRenders an <a> for http(s), mailto, and relative URLs. Cannot combine with action.
Icon-onlyhideLabel, iconRenders a square or circle icon trigger. Keeps label as the accessible name and enables tooltip by default.
ToggledefaultPressed or pressedTracks pressed state, sets aria-pressed, and applies a pressed tint. Plain buttons never set aria-pressed.
Action outcomestatus or promise return, optional showArrowMorphs through pendingLabel, successLabel, and errorLabel, then resets after resetAfterMs (2400ms default).
CopycopyValueWrites text (up to 200,000 characters) to the clipboard, confirms with a drawn check and "Copied", and resets after 1900ms.
SplitmenuItemsJoins 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.

Saving

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' },
  ]}
/>

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.

ArgumentType / defaultDescription
labelstringDefault: "Button"Visible text and accessible name. Name the action and its object, e.g. "Save changes".
variantsolid | soft | outline | ghost | linkDefault: "solid"Fill treatment: solid for the main action, soft, outline or ghost for others, link for text-like actions.
toneneutral | 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.
sizexs | 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.
shapedefault | 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.
iconIconName—Decorative icon before the label. Any name from the Icons page.
endIconIconName—Decorative icon after the label, from the same names. Directional icons mirror in RTL.
hideLabelbooleanDefault: falseIcon-only: show only the icon (needs one); the label stays the accessible name, and the button becomes a controlHeight square.
tooltipbooleanDefault: falseWhile 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.
shortcutstring—A keyboard shortcut shown in the tooltip after the label, e.g. "⌘K". Display only: the application binds the key.
tooltipPlacementPlacementDefault: "top"Preferred side of the tooltip. Collision detection flips it when there is no room.
loadingbooleanDefault: falseShow a spinner in place of the content. The width is kept, the button stays focusable, and activation is blocked.
loadingLabelstringDefault: "Loading"Announced to assistive technology when loading starts, e.g. "Saving".
statusidle | 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.
pendingLabelstringDefault: "Saving"Shown while the outcome is pending, e.g. "Saving".
successLabelstringDefault: "Saved"Shown when the outcome is success. "Saved", or "Copied" when copyValue is set.
errorLabelstringDefault: "Failed"Shown when the outcome fails, e.g. "Failed".
showArrowbooleanDefault: falseA trailing arrow at rest that leaves forward on pending and success while a drawn check enters (Arc action-button).
resetAfterMsinteger—How long a success or error result shows before returning to idle, ms. 0 keeps it. Unset: 2400, or 1900 for a copy.
copyValuestring—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.
defaultPressedboolean—Initial pressed state (toggle mode). Edits do not reset a mounted instance; in compositions the stored state wins.
menuItemsMenuItem[]—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.
menuLabelstringDefault: "{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.
menuPlacementPlacementDefault: "bottom-end"Preferred side and alignment of the menu. Collision detection flips it when there is no room.
fullWidthbooleanDefault: falseStretch to the width of the container.
typebutton | submit | resetDefault: "button"Native type inside a form. Ignored for links.
actionstring—Name of an action registered by your application. Sent to onAction when the button is activated.
hrefstring—Navigate to this URL instead of sending an action. Renders a link; http(s), mailto and relative URLs only.
disabledbooleanDefault: falseUnavailable and removed from the tab order. A disabled link loses its URL.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeButtonTheme—Color mode, accent, and semantic tokens. The attached menu follows the mode and accent.
motionnone | subtle | expressiveDefault: "subtle"Press, swap and menu animation preset. System reduced-motion preferences take precedence.
motionOptionsButtonMotionOptions—Press scale (omitted, it follows the width), and label swap duration (ms) and travel (px).
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

React integration

PropPurpose
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, onStatusChangeControlled outcome status (idle, pending, success, error) and change callback.
onCopyResult(copied)Called after each copy attempt with whether the clipboard accepted the text.
pressed, onPressedChangeControlled toggle state and change callback; use defaultPressed for uncontrolled toggles.
open, onOpenChangeControlled split menu open state and change callback.
checked, onCheckedChangeControlled checkbox and radio state for split menu items, keyed by item ID.
portalContainerMount container for the split menu portal.
renderIcon(name, context)Replaces named icons (including the success check) with custom decorative icons.
presetComponent defaults overridden by explicit instance props.
tokens--ui-* CSS variables applied after the typed theme on all segments and attached popups.
refRef to the rendered <button>, <a>, or split <div> group.
className, styleAdded to the root element; style wins over motion and theme tokens.
Native attributesForwarded attributes including id, aria-*, title, form, name, target, and rel.

Keyboard & accessibility

KeyInteraction
TabMoves focus to the button with a focus ring.
Enter, SpaceActivates buttons; links activate with Enter.
Arrow DownOpens 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": []
}

On this page