---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Button

A button with words that runs an action, in several looks and sizes, on a page, in a row or in a sidebar, for React and Tailwind CSS. Free, MIT.

Free. Its export: `Button`.

## Try it

Switch every look, shape and size; change the words; add the icon; make it disabled or busy. Press it (pointer or keyboard) and the count under it goes up, but never while disabled or busy (busy keeps its width and the focus).

Nothing is saved: the press is only counted.

## When to use

- A button with words that runs an action, in several looks and sizes, on a page, in a row or in a sidebar.

## When not to use

- For an icon alone use IconButton.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Button on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/meadow-button
```

```text
Add the Goop Button to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { Button, ButtonEnd, ButtonIcon, ButtonLabel } from '@/components/ui/goop/button';

function FieldNoteFilters({ filter, onFilter }: { filter: 'all' | 'mine'; onFilter: (next: 'all' | 'mine') => void }) {
  return (
    <div className="flex gap-1">
      <Button variant={filter === 'all' ? 'subtle' : 'ghost'} onClick={() => onFilter('all')}>
        <ButtonLabel>
          All notes
          <ButtonEnd>12</ButtonEnd>
        </ButtonLabel>
      </Button>
      <Button variant={filter === 'mine' ? 'subtle' : 'ghost'} onClick={() => onFilter('mine')}>
        <ButtonLabel>
          Mine
          <ButtonEnd>4</ButtonEnd>
        </ButtonLabel>
      </Button>
    </div>
  );
}

function ShareAction({ share, sharing }: { share: () => void; sharing: boolean }) {
  return (
    <Button variant="inverse" size="lg" className="w-full" loading={sharing} loadingLabel="Sharing" onClick={share}>
      Share survey
    </Button>
  );
}

function AccountActions({ exportNotes, deleteAccount }: { exportNotes: () => void; deleteAccount: () => void }) {
  return (
    <div className="flex gap-2">
      <Button variant="secondary" size="page" onClick={exportNotes}>
        Export notes
      </Button>
      <Button variant="destructive" size="page" onClick={deleteAccount}>
        Delete account
      </Button>
    </div>
  );
}

function SurveySync({ sync, newSurvey }: { sync: () => void; newSurvey: () => void }) {
  return (
    <div className="flex items-center justify-between gap-3">
      <Button variant="link" size="inline" onClick={newSurvey}>
        <ButtonIcon icon="plus" />
        New survey
      </Button>
      <Button variant="success" size="row" onClick={sync}>
        Sync photos
      </Button>
    </div>
  );
}

function ShareSurvey({ email }: { email: () => void }) {
  return (
    <div className="flex flex-wrap gap-1.5">
      <Button variant="chip" onClick={email}>
        <ButtonIcon icon="mail" />
        Email
      </Button>
    </div>
  );
}
```

- Fits: account, app, board, chat, flow, list, record, schedule, settings, states (their recipes).
- The button is as wide as its words wherever it stands; an action that fills its row takes the caller's class, `className="w-full"`, and a settings section's pair of actions one width each, `className="w-32"`. A full-width pair, the main one dark, stacks 12 px apart: `<div className="flex flex-col gap-3"><Button variant="inverse" size="lg">Start a recording</Button><Button variant="outline" size="lg">Add a file</Button></div>`. With `asChild` it marks the child busy and stops its presses; the child draws its own spinner. On a touch screen it is at least 44 px high and wide by itself, no prop.
- More on where it goes: button--options.md
- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.

## API reference

### Options

- `variant: primary | inverse | outline | ghost | subtle | secondary | destructive | success | link | chip | nav | text = primary`
- `size: sm | md | row | page | lg | xl | inline = md`
- `shape: pill | rounded = rounded`

- Each option with its sentence: button--options.md

### Parts

- `ButtonLabel` — The button's words where a count follows them
- `ButtonEnd` — The button's trailing run inside its `ButtonLabel`
- `ButtonIcon` — A pack icon in the button, before its words; its props: button--icon.md

- Class recipes (cva): buttonVariants (Button)
- data-slot values (to select a part by): button, button-end, button-icon, button-label, button-spinner

### ButtonIcon

A pack icon in the button, before its words.

```tsx
import { ButtonIcon } from '@/components/ui/goop/button';
```

### Options

- icon: IconName — A pack icon name.

### Button: every option

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

### Compose

- A leading icon is the pack's `Glyph` before the words — the text action's `<Button variant="link" size="inline"><Glyph icon="tabler-outline:circle-plus" aria-hidden="true" />Create</Button>` — 4 px from them at the row and inline sizes. Raised chips stand in a wrapping row 6 px apart, each leading with the caller's own mark (a `ButtonIcon`, drawn in the icon grey on a chip, or an element of your own in 16 px): `<div className="flex flex-wrap gap-1.5"><Button variant="chip"><ButtonIcon icon="mail" />Email</Button></div>`.

### Options

- variant: primary (default), inverse, outline, ghost, subtle, secondary, destructive, success, link, chip, nav, text
- size: sm, md (default), row, page, lg, xl, inline
- shape: pill, rounded (default)
- asChild?: boolean = false — Render the button's look on the one child element instead of a `button` (a link, a menu's trigger).
- loading?: boolean = false — The button's action is running: a spinner over its words (the width kept), and no press reaches `onClick` or submits; it keeps the focus.
- loadingLabel?: string = 'Loading' — What a reader hears beside the button's words while `loading` (default "Loading").
- Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean

## Keyboard

- Enter: activate
- Space: activate

## Accessibility

- The native element answers the keyboard.
- hover, active, focus, focus-visible: the browser's own (:hover, :active, :focus, :focus-visible): write nothing
- disabled: the prop disabled

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Icon button](/themes/meadow/components/icon-button): A button whose one visible label is a pack icon, for toolbars, rows and headers, with a spoken name.
- [Button group](/themes/meadow/components/button-group): Joined buttons, and a SplitButton: a main action with its menu.
- [Destructive button](/themes/meadow/components/destructive-button): The button for an action that deletes or cannot be undone, marked in the danger colour.
- [Toggle button](/themes/meadow/components/toggle-button): A button that stays pressed until it is pressed again.
