Skip to content
Toolkit

ADR-0033: The button that was two buttons, and the three words that changed meaning

Context

Button was the workstream's second-largest surface — 72 files, 291 uses, of which four lived in the component's own stories and were archived with it, leaving 287 uses across 71 files to move — and the one where both sides already had the name, both sides already had the component, and almost nothing about the two agreed.

The census is cheap for the same reason Input's was: every use is statically visible. Zero {...spread} sites, zero refs, one style. What the JSX says is everything there is.

App propUsesWhere it lands in Studio
variant182 explicit (+109 defaulted)variant, with three words remapped
size185, all "sm"size="sm" — the axis had to be authored (152 after the icon-only split)
loading57loading — authored
iconLeft / iconRight38 / 1, all lucide elementsicon / iconAfter, widened to take one
disabled50passthrough — but the layer drew no disabled state
aria-label34IconButton.label on 33 of them — and 14 more controls had no name at all
fullWidth0did not survive

One export, two jobs

Input split four ways because its props hid four jobs (ADR-0032). Button splits two ways, and the second job is not hidden in a prop at all — it is visible in the shape of the call:

<Button variant="ghost" size="sm" onClick={…} aria-label={`Delete link ${l.url}`}>
  <Trash2 size={14} strokeWidth={1.75} className="muted" />
</Button>

Forty-seven uses across twenty-two files are that: one glyph as the whole content and a ghost/sm pair to make the button small and quiet — with, on thirty-three of them, an aria-label, because a glyph is not a name. The other fourteen had no name at all; see the consequences. That is IconButton's entire job description, and Studio has had IconButton since before the workstream started — with zero app consumers, because the app had a Button that could be talked into the same shape. The difference is that IconButton's label is required: an icon-only control with no accessible name is a bug there rather than an option. Mapping these to Button would have preserved a convention where a construction was available.

The rule the prop census does not show

Every count above is a count of props, and a prop census cannot see the declaration that changes for all 287 uses at once. ADR-0023 recorded this escape on DataTable — the rule you are comparing has other declarations in it — and it applies here to the base rule itself:

app .btnStudio .lk-btn
height42px40px
border-radius--r-md (14px)--r-pill
font-size13.5px14px
font-weight600500
border0.5px solid transparentnone

and for the 138 sm buttons: padding-inline --space-3 (12px) → --space-4 (16px), font-size 12.5px → 13px, radius --r-sm (10px) → pill. (The app's own .btn-ghost.btn-sm was already a pill, which is 33 of them.) None of this is a regression — it is the point of adopting a design system's button rather than transcribing its variants — but it is a change to every button in the product, and a conversion that lists three deliberate visual changes while this one goes unmentioned has mis-stated its own blast radius. The weight step is the one to watch: .medium text beside a button is also 500 now.

Three words that survived and changed meaning

ADR-0026's rule earns its keep here more than anywhere. All three of these compile, render a button, and are wrong:

  • danger. The app's danger was the filled --error button (.btn-danger { background: var(--error) }). Studio's danger is the quiet ghost with --error text, and the fill is destructive. All four uses meant the fill. A blind import swap would have turned four irreversible-action buttons into faint text.
  • secondary. 105 uses — the app's workhorse quiet button, drawn as .btn-neutral: a solid --on-surface fill with --background ink and a raised shadow. Studio has no inverted solid, and DESIGN.md specifies three button variants (primary, ghost, icon) plus the destructive pair. Its quiet-but-visible button is outline: surface fill, hairline, flat shadow. These moved there.
  • The default itself. The app defaulted to primary; Studio defaults to ghost. 109 call sites named no variant at all, and every one of them had to start saying primary out loud or silently become a ghost. This is the change with the widest blast radius in the whole conversion and the only one with no textual trace at the call site to find it by — you cannot grep for a prop that isn't there.

What the layer did not say

The enumeration (ADR-0023, Method step 4) against studio.components.css — the layer apps/web/src/index.css imports, not the bundle and not the preview page — found four gaps, three of them states the markup asserts on hundreds of call sites:

  • No :disabled rule at all. The only :disabled in the layer was .lk-pagination__nav .lk-btn--icon:disabled. 50 uses pass disabled and 57 more pass loading, which disables: a button that looked perfectly pressable and silently was not.
  • No :focus-visible radius. The app's unscoped base.css :focus-visible sets border-radius: 6px at (0,1,0) and is imported after the layer, so every pill button focused as a rectangle. Fifth instance of that trap — .lk-toggle, .lk-tabs__tab, .lk-textarea and the password reveal each carry the same fix.
  • No size axis. .lk-btn--sm did not exist. 185 of the uses wanted it — 138 once the 47 icon-only ones moved to IconButton, which is one fixed size.
  • .lk-btn--danger was not in the layer. It lived in 70-patterns.css, which reaches studio.css and not studio.components.css — so the danger variant rendered as an unstyled button for any consumer importing the component layer, which is every consumer this repository has.

Decision

The 287 uses convert to two components by job: IconButton for the 47 icon-only controls — every one of them a variant="ghost" size="sm" — and Button for the other 240.

One icon-only site stays a Button on purpose: DomainsPage's verify control is the only one of the 34 that is also a loading button, and IconButton has no busy state. It keeps its glyph, its aria-label and its spinner rather than losing the spinner to gain the component. If a second one ever appears, the answer is a busy state on IconButton, not a second exception.

variant remaps rather than transfers: 109 defaulted uses gain variant="primary", 105 secondary become outline (103 literal and the two computed cond ? 'secondary' : 'primary' branches), 4 danger become destructive. outline (1) and explicit primary (4) keep their word, as do the 17 ghost uses left after the IconButton split. link had zero call sites and does not survive — .btn-link stays in the app sheet because the topbar hand-rolls one. The result, measured after the change: primary 113, outline 104, ghost 17, destructive 4, plus the two computed branches, and every one of the 240 now names its variant rather than inheriting one.

Studio's Button is raised, not adopted as-was (ADR-0019), in four ways, each of them something a call site already asked for:

  1. size="sm" — a 34px control, .lk-btn--sm, with its own glyph sizing. There is deliberately no lg: no call site in the repository ever passed one, so the axis has exactly the value that was used.
  2. loading — disables, sets aria-busy, and swaps the leading glyph for a drawn spinner (ADR-0024). The app imported Loader2 from lucide; a Studio component cannot, and an icon-font class would have left all 57 sites looking idle while refusing to be pressed.
  3. icon/iconAfter take an element as well as a class name. This is not a convenience: 100% of the 39 icon passes in the app are lucide elements and zero are strings, so without it the entire icon surface of the conversion had nowhere to land.
  4. .lk-btn:disabled and .lk-btn:focus-visible join the layer, and .lk-btn--danger moves into it from 70-patterns.css.

IconButton and Segmented are widened in the same pass, because ADR-0024's rule is about the module that is converting, not only the export: both take an element icon now. renderIcon — the helper overlays.jsx wrote for the menu — moves to controls.jsx and is shared rather than copied, so ADR-0024 has one implementation.

The types landed first (Method step 3): ButtonProps, IconButtonProps, SegmentedProps and the shared StudioIcon alias in index.d.ts, written before a call site moved and proved with six deliberately wrong calls that tsc rejected — variant="secondary", variant="danger2", size="lg", an IconButton with no label, a Segmented option with no label, and loading="yes". The button family was the largest remaining untyped block in the package; Badge and Chip are what is left.

Consequences

  • The parity gate goes from 2 awaiting conversion to 1: only Card remains. App-side components 14 → 13. React and Swift counts are unchanged — nothing new was authored, three exports were raised.
  • Three deliberate visual changes, all toward what DESIGN.md specifies:
    • 105 secondary buttons stop being an inverted solid and become the hairline outline button;
    • the 17 remaining ghost buttons lose their resting --surface-2 fill (Studio's ghost is transparent until hover);
    • 47 row-action buttons become 36px round IconButtons where they were 34px ghost pills.
  • Every button now draws a disabled state and focuses as the pill it is. These are the conversion's two silent bug fixes, and they apply to every consumer of the layer, not only to the sites that moved.
  • The ADR-0021 sweep, counted. Deleted — Button.tsx was the sole emitter of each in the repository: .btn-danger (2 rules), .btn-lg (1), .btn-spinner (1), and the two shell.css selectors that reached through .btn-label (which has no standalone rule anywhere). Kept, with their surviving emitters: .btn (9 className positions across 7 files), .btn-primary (4), .btn-sm (7), .btn-block (3), .btn-ghost (2), .btn-outline (2), .btn-neutral (1, LoginPage), .btn-link (1, Topbar), and the .btn:disabled / .btn:active / .btn-ghost.btn-sm rules that go with them.
  • fullWidth did not survive and nothing was lost: the prop had zero call sites. The seven full-width buttons pass className="full-width", the app utility they were already using, which passes through.
  • The conversion's one inline style went with it. FilterBar's primary action carried style={{ borderRadius: 'var(--r-pill)' }}, which existed only because the app's .btn was --r-md and this one button wanted the pill. .lk-btn is the pill, so the override now says nothing — and it was the hardcoded value AGENTS.md #3 forbids, kept alive by the component this conversion replaced.
  • Fourteen more controls gained a name. The first census counted the 34 icon-only buttons that had an aria-label; the adversarial pass asked after the ones that had none, and found fourteen — two on AdminThemesPage, one each on the four AI history pages and NotificationHandlersPage, six on PwasPage (two of them named by a title, which names a control for a mouse and for nobody else). Every one is a lone glyph on a ghost/sm button, announced as "button". They are IconButtons now, where label is required. This is the routing rule's own blind spot, worth writing down: "icon-only with an aria-label → IconButton" selects against precisely the controls the required label exists to fix. i18n 1979 → 1983 — ten of the fourteen names interpolate a row's title and are invisible to the counter, four are literals.
  • One button stopped submitting its form. AdminUsersPage's Cancel sat inside a <form onSubmit> with no type, and the app component set no default — so <button>'s own type="submit" applied and Cancel submitted the create-user form on its way to closing it. Studio's type="button" default fixes it. It is the only site in the repository with that shape, and it was found by the review rather than by the census, because a census of props cannot see a prop nobody passed.
  • IconButton's required label is a runtime guarantee, not a type one. The type cannot stop a caller passing aria-label beside it: TypeScript exempts hyphenated JSX attribute names from excess-property checking, so aria-label="" type-checks against any component at all (verified — Omit-ing it changes nothing, while a non-hyphenated bogusProp errors). The component therefore spreads rest before the name it is responsible for, and a test holds that ordering still.
  • Segmented was typed for props its runtime dropped. It declared Omit<HTMLAttributes<HTMLDivElement>, …> and destructured six props with no ...rest, so id, style and data-* type-checked and vanished. It spreads now. Proving a type rejects what it should is half a proof; the other half is that what it accepts arrives.
  • Two findings are left as open items rather than fixed here, because fixing either would be the adjacent cleanup the routine forbids: .sidebar-compose has no emitter anywhere in the app, so the sidebar rail's compose-button rules in shell.css were already dead before .btn-label left (only the .btn-label selectors — the ones this conversion made unreachable — were removed); and seven hand-rolled .btn buttons now sit beside converted ones and no longer match them, which is the base-rule diff above made visible. Three surfaces are worth naming: LoginPage's OAuth provider buttons (below a Divider from the converted Sign in), QrCodesPage's edit link beside its new IconButton, and QrCodeBuilderPage's Download PNG stacked with two converted buttons. None is convertible by this conversion: five are <a>/<Link> elements and Studio's Button has no as, and the OAuth ones carry a per-provider brand background as an inline style. Both are authoring questions, recorded as such.
  • .lk-seg is still outside the component layer (open item 19), so Segmented's widened icon prop is typed and drawn but unstyled for a component-layer consumer. It has no app call sites; the row stays open.
  • The i18n ratchet does not move: the conversion introduces no new literals. aria-label values became IconButton.label values, and label is already in TEXT_ATTRIBUTES.

Verification

npm run verify exits 0. The behavioural test is apps/web/src/components/Button.test.tsx (23 tests); fourteen mutations were watched biting before the assertions were trusted — .lk-btn--sm's height changed to the default, .lk-btn:focus-visible deleted, .lk-btn:disabled deleted, .lk-btn--danger pushed back out of the layer, icon reverted to string-only, the default variant put back to primary, loading no longer disabling, IconButton's label no longer becoming aria-label, and size ignored; then five more for the assertions the adversarial pass added — IconButton spreading rest after its name again, IconButton dropping className, Button swallowing title (the only accessible name two PwasPage controls had), children wrapped in a span again, and .lk-btn--destructive's fill changed. Each failed at least one test, and the suite was restored to green after each. Two assertions the pass found vacuous were replaced rather than kept: a .btn-label absence check that no mutation of a Studio component could ever fail, and a [class*="ph-"] check in a test whose only icon was an element.

.station/jobs/002-renaissance/preview/current-design.html's two Button cards are retired to a converted card on the same commit (ADR-0021's step 5, the Kbd precedent): three of the classes they drew left components.css here, so the page would have rendered its own Danger, Large and spinner samples broken. The icon-button samples stay — three hand-rolled lineages the conversion did not touch. Layer assertions parse rules and match exact selectors (the Textarea.test.tsx discipline), against studio.components.css.

Source: docs/decisions/0033-the-button-that-was-two-buttons.md

Library