Skip to content

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.

Solid (importance)
Outline
Ghost
Link

Importance levels

LevelUse case
primaryMain call-to-action (save, confirm, navigate forward)
secondarySecondary action or softer CTA
destructiveIrreversible or dangerous action (delete, clear)
neutralCancel, dismiss, or low-emphasis action

Style groups

StyleWhen to use
SolidHigh-emphasis, prominent placement
OutlineMedium-emphasis, adjacent to a solid button
GhostLow-emphasis, toolbar actions
LinkInline 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

WhereButtons
row 1 and row 2 of a list headericon buttons (size="icon"), with the word from lg up. Toggles use neutral when on, neutral-ghost when off
the Select mode barCancel (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.

RuleWhy
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:

ActionIcon
Cancel, ClearX
Done, SaveCheck
EditPencil
Add, New …Plus (Invite: UserPlus)
settings, ManageSettings
BackArrowLeft

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 barCancel dropsMain action
shopping cartthe items in the cart (after a confirm)Done (Check)
cookingthe recipes and amounts picked (after a confirm)Done (Check)
the Select mode barthe items pickedEdit (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>

Resources