npx shadcn@4.23.1 add @goop/meadow-buttonButton
FreeA 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.
What an agent sees
- ButtonLabelThe button's words where a count follows them
- ButtonEndThe button's trailing run inside its
ButtonLabel - ButtonIconA pack icon in the button, before its words
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>
);
}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.
npx shadcn@4.23.1 add @goop/meadow-buttonAdd the Goop Button to this project. The install steps are at https://goop.so/docs/install.mdUsage
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>. WithasChildit 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
| Option | Type | What it does |
|---|---|---|
| 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
| Part | What it is |
|---|---|
| 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.
import { ButtonIcon } from '@/components/ui/goop/button';Options
- icon: IconName — A pack icon name.
Button: every option
import { Button } from '@/components/ui/goop/button';Compose
- A leading icon is the pack's
Glyphbefore 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 (aButtonIcon, 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
onClickor 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
| Key | What it does |
|---|---|
| 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
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| 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.