Skip to content
Browse docs and components

Button

button

The primary action element. Four variants and three sizes, gradient primaries that crossfade on hover rather than snap, and an icon contract where the button owns the icon size. No client boundary, so it works in a server component and ships no JavaScript.

Responsive

Install

$npxshadcnadd@forme/button

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import { Plus } from "lucide-react";
import { Button } from "@/components/forme/button/button";

<Button leadingIcon={Plus}>New project</Button>
<Button variant="secondary">Cancel</Button>

When to use

Reach for it

  • Any action on the page: submitting a form, opening a dialog, starting a task.
  • ButtonLink for something that looks like a button but navigates.

Use something else

  • Navigation inside running text — that is a link.
  • Destructive actions that need a second step; reach for ConfirmButton or HoldButton.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

Button

PropTypeDefaultDescription
variant'primary' | 'secondary' | 'ghost' | 'danger'"primary"
size'small' | 'medium' | 'xs'"medium"
iconOnlybooleanfalseSquare, icon-only. Requires an aria-label: the icon is decorative, so without a label the button has no accessible name at all.
leadingIconButtonIcon—
trailingIconButtonIcon—
loadingbooleanfalseShows progress without losing the button. A loading button stays focusable and keeps its label in place, so the width does not jump mid-click and the keyboard focus does not disappear under the person using it.
asChildbooleanfalseRender as the single child element instead of a <button>, keeping the styles and the keyboard behaviour.

Also takes every prop of <button> attributes.

ButtonLink

PropTypeDefaultDescription
variant'primary' | 'secondary' | 'ghost' | 'danger'"primary"
size'small' | 'medium' | 'xs'"medium"
iconOnlybooleanfalse
leadingIconButtonIcon—
trailingIconButtonIcon—

Also takes every prop of <a> attributes.

Accessibility

  • A native <button>, so Enter, Space and the disabled state are the browser's own.
  • An iconOnly button needs an aria-label: its icon is decorative and has no name of its own.
  • While loading it is aria-disabled and aria-busy rather than disabled, so it keeps focus and its width.

Motion

  • None. Hover and press change colour on the frame they happen, and press is a darker step, never a scale.