nook
Browse the docs

Components

Button

Native

Triggers an action. Comes with variants, sizes and a loading state, and exports its styles for links.

See the prompt

Installation

npx nook-ui@latest add button

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Button" component to this project, exactly as Nook ships it.

Triggers an action. Comes with variants, sizes and a loading state, and exports its styles for links.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add button`. It writes `components/ui/button.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/button.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
import { Button } from "@/components/ui/button";

export default function ButtonVariants() {
  return (
    <div className="flex flex-wrap items-center gap-3">
      <Button>Default</Button>
      <Button variant="secondary">Secondary</Button>
      <Button variant="outline">Outline</Button>
      <Button variant="ghost">Ghost</Button>
      <Button variant="destructive">Delete</Button>
      <Button variant="link">Link</Button>
      <Button disabled>Disabled</Button>
    </div>
  );
}
```

API
- `Button`: The button element.
  - `loading` (`boolean`, default false): Shows the loader and ignores presses.
  - `...props` (`React.ButtonHTMLAttributes<HTMLButtonElement>`): Everything the native element accepts, such as `id`, `aria-*` and event handlers.
- Variant `variant`: default, secondary, outline, ghost, destructive, link (default default)
- Variant `size`: sm, md, lg, icon (default md)

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Renders a native button with type=button by default. While `loading`, the button sets `aria-busy`, ignores presses and keeps keyboard focus. To make a link look like a button, put `buttonVariants()` on the anchor.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { Button } from "@/components/ui/button";

export default function ButtonVariants() {
  return (
    <div className="flex flex-wrap items-center gap-3">
      <Button>Default</Button>
      <Button variant="secondary">Secondary</Button>
      <Button variant="outline">Outline</Button>
      <Button variant="ghost">Ghost</Button>
      <Button variant="destructive">Delete</Button>
      <Button variant="link">Link</Button>
      <Button disabled>Disabled</Button>
    </div>
  );
}

Examples

Sizes

Sizes follow the density token, so compact themes shrink them.

Loading

The loader takes the place of the icon and the button keeps focus.

As a link

Use buttonVariants() to style an anchor like a button.

With icons

An icon before or after the label. The gap and size come from the button.

Icon only

Icon buttons always need a name for screen readers.

Disabled

Every variant dims and stops reacting. Explain why nearby when you can.

Publishing is off until the title has at least three words.

Full width and stacked

Forms and cards often want one wide button per row.

Upgrade to Team

Ten seats, shared boards and a 90-day history.

Loading in every variant

The label stays, so the button keeps its width while it works.

Confirm and cancel

A dialog footer: the safe choice on the left, the action on the right.

Remove Q3 roadmap and its 14 cards? You can restore it from the trash for 30 days.

Variants

Defined in one place with cva, at the top of the component file.

  • variant

    default (default)secondaryoutlineghostdestructivelink

  • size

    smmd (default)lgicon

Props

Button

The button element.

PropTypeDefaultDescription
loadingbooleanfalseShows the loader and ignores presses.
...propsReact.ButtonHTMLAttributes<HTMLButtonElement>–Everything the native element accepts, such as `id`, `aria-*` and event handlers.

Accessibility

Renders a native button with type=button by default. While `loading`, the button sets `aria-busy`, ignores presses and keeps keyboard focus. To make a link look like a button, put `buttonVariants()` on the anchor.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.