Button

Six variants, three sizes, a loading state that keeps its width, and an icon button that insists on a label.

Category
Forms
Access
Free with an account
Source
123 lines · one file
Added
4 Oct 2026

The decision inside it

Loading keeps the width

A button that shrinks when its label turns into a spinner moves everything beside it. The label stays in the layout, invisible, and the spinner sits over it; `aria-busy` tells a screen reader what happened.

When to use it

Use Button for actions: primary, secondary, outline, ghost, destructive and link variants, with an icon, a loading state and asChild for links. IconButton is the square icon-only button and requires a label for screen readers.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Button for this.
Install it: npx shadcn@latest add @liro/button
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/button.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/actions.tsx
import { Trash2 } from "lucide-react";
import { Button, IconButton } from "@/components/ui/button";

export function Actions({ saving, save, remove }: { saving: boolean; save: () => void; remove: () => void }) {
  return (
    <div className="flex gap-2">
      <Button onClick={save} loading={saving}>Save changes</Button>
      <Button variant="outline" asChild>
        <a href="/settings">Settings</a>
      </Button>
      <IconButton label="Delete" variant="ghost" onClick={remove}>
        <Trash2 className="h-4 w-4" />
      </IconButton>
    </div>
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
variantButtonVariant NoHow much attention the action deserves. Default `primary`.
sizeControlSize NoMatches Input and Select of the same size. Default `md`.
iconboolean NoSquare, for a single icon. Give it an `aria-label` — or use IconButton, which requires one.
loadingboolean NoShows a spinner in place of the leading icon and marks the button busy.
asChildboolean NoRender the child element (a link, say) with the button's styling instead of a `<button>`.
shape"rounded" | "pill" No`rounded` is the squircle that matches inputs; `pill` is fully round, for marketing pages and toolbars of pills. Default `rounded`.

Dependencies

npm packages

@radix-ui/react-slotclsxlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-theme

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances

Used in screensAll screens