Skip to content

Fancy button

The app button on Underlay's control language: basic, primary, neutral and destructive, with pending and done states.

One primary per view, basic beside it, neutral for a submit inside its context (Reply, Send), destructive for deletion. xsmall (30px, the default) is for toolbars and page chrome, small (36px) for dialog and sheet footers, medium (40px) for full-width actions on a phone. FancyButtonIcon takes the icon component in as, so its file is a client component; put the label in a <span> beside it and the button tightens the padding on the icon's side.

Variants

Sizes

With icon

Icon only

Disabled

Pending

Pending then done

Installation

npx shadcn@latest add @khaeli/fancy-button

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @keyline-icons/react ^2.2.0
  • @radix-ui/react-slot ^1.1.0

Keyboard

EnterSpace
Activates the button. While it is pending or shows its done label, the press does nothing.
Tab
Moves focus to the button. A disabled button leaves the tab order. A pending button stays in it as aria-disabled, so focus is not lost while the request runs.

Accessible name

  • The name is the button's text. Keep it a verb that says what happens: Save changes, not OK.
  • An iconOnly button has no text, so give it an aria-label. FancyButtonIcon hides its icon from assistive technology.
  • While pending, the button keeps the label you give it and is exposed as disabled with aria-disabled. Change the label to say what is happening, such as Saving. The loader is hidden from assistive technology.
  • With status, the done label (doneLabel, Saved unless you set it) replaces the text for a moment and is announced once by a polite live region inside the button.
  • With asChild the child is the element: a link stays a link and is announced as one. It shows no loader and no done label.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/fancy-button.json