Button
UI SDK Button with variants: async pending state, a loading prop with a spinner, focusable-when-disabled, link rendering, and a tooltip with its name (and shortcut) on an icon button. ButtonLink is a Link with the Button look, for calls to action that navigate.
Example
Copy linkArchiveMoves the draft to the trash
button-demo.tsxCopy code
Installation
Copy code
Usage
ImportCopy code
API reference
Button
| Prop | Type | Default |
|---|---|---|
variant | "default" | "secondary" | "outline" | "ghost" | "destructive" | "link" | "default" |
loadingShows a spinner, sets `aria-busy` and ignores presses while keeping focus, for work this button didn't start. | boolean | – |
wrapLets a text button shrink and wrap its label onto more lines in a tight row, instead of overflowing it. | boolean | – |
shortcutA key that presses the button while it is mounted, in the enclosing `ShortcutScope`: `"u"`, `"mod+s"`, `"g i"`. Shows the keys after the label and sets `aria-keyshortcuts`. People only: agents press the button by name. | string | – |
shortcutDescriptionWhat `ShortcutsDialog` lists the shortcut as; defaults to the `aria-label` or a plain-text label. | string | – |
shortcutHint`false` binds the key without showing it. | boolean | true |
shortcutWhenChecked on every key press: `false` leaves the key to the page, like Cmd/Ctrl+Z to a focused text field. | () => boolean | – |
tooltipAn icon button shows its `aria-label`, and its shortcut, in a tooltip on hover and keyboard focus. `false` turns it off when a visible label sits beside the button; a string or `{ content, side, align }` replaces or places it, on any button. | ControlTooltipOption | – |
size | "sm" | "default" | "lg" | "icon" | – |
aria-label | string | – |
Also takes every prop of UI SDK Button except aria-label.
ButtonLink
| Prop | Type | Default |
|---|---|---|
variantThe Button look: a call to action that navigates is still a link. | ButtonVariantProps["variant"] | "default" |
size`icon` needs an `aria-label`. | Exclude<ButtonVariantProps["size"], null> | "default" |
Also takes LinkProps except variant.
Other exports
buttonVariantswithPendingSpinnertype ButtonLookPropstype ButtonPropstype ButtonLinkPropsAccessibility
- A real <button> from UI SDK: Enter and Space, focus ring, disabled that can stay focusable.
- While pending it sets aria-busy, ignores presses and keeps focus; pendingAnnouncement is read after a second.
- size="icon" requires aria-label at the type level, and shows it in a tooltip that labels the button, so the name is heard once.
Agent actions
Agents press it by its text, or an icon button by its aria-label; its tooltip stays out of the snapshot. With data-agent-confirm, the press waits for your allow callback.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.