Button
The Button component is used for all interactive actions in the app. It is built on shadcn/ui with a custom variant system driven by the app’s semantic design tokens.
Variants
Buttons are organised into four style groups (solid, outline, ghost, link) across four importance levels (primary, secondary, destructive, neutral), giving 16 variants in the importance group plus 20 hue-colored variants for tag contexts.
Importance levels
| Level | Use case |
|---|---|
primary | Main call-to-action (save, confirm, navigate forward) |
secondary | Secondary action or softer CTA |
destructive | Irreversible or dangerous action (delete, clear) |
neutral | Cancel, dismiss, or low-emphasis action |
Style groups
| Style | When to use |
|---|---|
| Solid | High-emphasis, prominent placement |
| Outline | Medium-emphasis, adjacent to a solid button |
| Ghost | Low-emphasis, toolbar actions |
| Link | Inline text-level actions |
Sizes
Available sizes: xs, sm, default (h-8), lg, plus square icon sizes icon-xs, icon-sm, icon, icon-lg.
Toolbar buttons
| Where | Buttons |
|---|---|
| row 1 and row 2 of a list header | icon buttons (size="icon"), with the word from lg up. Toggles use neutral when on, neutral-ghost when off |
| the Select mode bar | Cancel (destructive-ghost, X) and Edit (the filled default, Pencil), both top bar actions (next sections) |
See List Toolbars.
Top bar actions on a phone
On a phone, an action button in a top bar shows only its icon, with an accessible name. From lg (1024 px) up it shows the icon and the text.
A top bar is row 1 of a page, the Select mode bar that replaces it, the Toolbar of a list page, and the bar of an inner page (LayoutInnerPages). Dialogs and row 2 list controls are not top bars. The shopping cart page is the model.
| Rule | Why |
|---|---|
size="icon" and className="lg:w-auto lg:px-3" | a square 32 px button on a phone, a normal button from lg up |
the icon in icon={…} | it stays when the text is hidden |
aria-label={label} | the button keeps its name on a phone. The name is the same word as the visible text on desktop (WCAG 2.5.3) |
the text in <span className="hidden lg:inline">{label}</span> | it shows only from lg up |
<Button size="icon" className="lg:w-auto lg:px-3" icon={<Plus />} aria-label={t('settings.recipes.newButton')} onClick={…}> <span className="hidden lg:inline">{t('settings.recipes.newButton')}</span></Button>Use the same icon for the same action everywhere:
| Action | Icon |
|---|---|
| Cancel, Clear | X |
| Done, Save | Check |
| Edit | Pencil |
| Add, New … | Plus (Invite: UserPlus) |
| settings, Manage | Settings |
| Back | ArrowLeft |
In tests, expectTopBarIconButton(button, label) (apps/web/src/test/topBarButton.ts) checks the classes, the icon and the name.
Top bar Cancel
Cancel in a top bar is always destructive-ghost with the X icon. The main action (Done, Edit, Save) is the filled primary button.
Red says “you lose what you picked”. That is true in every top bar with a Cancel:
| Top bar | Cancel drops | Main action |
|---|---|---|
| shopping cart | the items in the cart (after a confirm) | Done (Check) |
| cooking | the recipes and amounts picked (after a confirm) | Done (Check) |
| the Select mode bar | the items picked | Edit (Pencil) |
<Button variant="destructive-ghost" size="icon" className="lg:w-auto lg:px-3" icon={<X />} aria-label={t('common.cancel')} onClick={…}> <span className="hidden lg:inline">{t('common.cancel')}</span></Button>This is for top bars only. A Cancel in a dialog footer closes the dialog and keeps the edits, so it stays neutral-outline (see Forms). The onboarding Clear button is not a Cancel: it clears the picks and leaves no mode.
Usage
import { Button } from '@/components/ui/button'
// Importance variants<Button variant="primary">Save</Button><Button variant="neutral-outline">Cancel</Button><Button variant="destructive">Delete</Button>
// With size<Button variant="primary" size="sm">Save</Button><Button variant="primary" size="icon"><PlusIcon /></Button>