Controls Gallery — Buttons & Commands Page Spec
Inherits the shell, palette, pointer contract, keyboard contract, and
determinism rules from 00-controls-gallery-overview.md.
Goal
Demonstrate every command control across its full pointer state machine — hover, press, release, click — including icon-only, toggle, and split variants, with each activation counted and echoed.
Controls Demonstrated
Control |
Module |
Required |
Events |
Demonstrates |
|---|---|---|---|---|
button |
Button |
|
|
Primary, secondary, danger, ghost intents |
icon-button |
IconButton |
|
|
Icon-only command with tooltip |
toggle-button |
ToggleButton |
|
|
Product-owned pressed/on state |
split-button |
SplitButton |
|
|
Primary action plus secondary menu |
User Experience
The page shows a command bar of buttons in every intent, an icon-button toolbar, a row of toggle buttons whose on/off state persists, and a split button whose caret opens a menu of secondary actions. A live activation log shows the last few commands. Every button visibly transitions through hover → pressed → released as the pointer acts on it.
Layout
- A heading
Buttons & Commandsand description. -
A
WrapofButtoninstances: Primary, Secondary, Danger, Ghost, plus a Disabled button that ignores pointer input. - A
Toolbarrow ofIconButtons (e.g. save, copy, delete) each with a tooltip. -
A row of
ToggleButtons (e.g. Bold, Italic, Underline) holding independent on/off state. -
A
SplitButtonlabeledSavewhose caret opens a menu (Save,Save As…,Save All). - A right-hand activation log (
ListView) of the last 8 commands.
Mouse & Pointer Interactions
HoverEnter/HoverLeavedrive each button's hover state and tooltip.-
PressedDownshows the pressed fill;ReleasedUpinside the bounds firesClick; release outside the bounds cancels without firing. -
Clickon a button appends<id> clickedto the activation log and increments a per-button counter. Clickon a toggle button flips itsonTogglestate and recolors it.-
Clickon the split button's primary region firesonClick;Clickon its caret opens the secondary menu, and selecting an item firesonSelected. - The Disabled button shows no hover/press response and never fires.
Keyboard
Tabmoves across all commands in order.Enter/Spaceactivates the focused button or flips the focused toggle.Arrow Downon the focused split button opens its menu.
Core Behaviors
- A click is press-inside followed by release-inside; release-outside cancels.
- Intent (
primary/secondary/danger/ghost) drives the button's palette role. - Toggle state is product-owned and survives navigation away and back.
- The split button exposes both a primary command and a secondary menu.
- Disabled commands are inert to pointer and keyboard.
Data Model
- A button descriptor list (id, label, intent, enabled, click count).
- Per-toggle on/off state keyed by id.
- Split-button menu items and the selected secondary action.
- A bounded activation log (most-recent-first, capped at 8).
Visual / Palette Requirements
- Primary uses accent fill; secondary uses surface-raised with accent border; danger uses the danger role; ghost is borderless until hovered.
- Pressed uses the accent-hover shade; toggled-on uses accent-soft with accent text.
- The disabled button uses muted foreground and shows no state changes.
App State
Track: button descriptors and counts; toggle states; split-button menu and selection; activation log; hovered/pressed/focused ids.
Determinism and Evidence
- Evidence mode clicks one button of each intent, flips one toggle, opens the split menu and selects an item, and attempts the disabled button (no effect).
- Evidence outcome: click counts per button, toggle states, the selected secondary action, the disabled-button no-op, and close reason.
- Screenshot evidence shows one button mid-press, one toggle on, and the split menu open.
Acceptance Criteria
-
Every button transitions hover → pressed → released and fires
Clickonly on release-inside. - Release-outside cancels without firing.
- Each intent shows its correct palette role; ghost reveals on hover.
- Toggle state flips, recolors, and persists across navigation.
-
The split button fires
onClickfor the primary region andonSelectedfrom its menu. - The disabled button is inert.
Out of Scope
- Long-press, double-click, or chorded mouse gestures.
- Asynchronous command results or progress within a button.