Primitives
Button
The control everything else is measured against: an outlined box at the control weight that gains its block under the cursor. One button per view is the primary.
A default button rests flat and draws its 3px block for the first time
on hover, which is why the lift reads as a lift. --primary is the one
button that rests with a block already under it, so its hover deepens that
block to 6px instead - translating alone would move element and block
together and leave the lower-right edge exactly where it was, which reads as
the button growing. --ghost and --dashed drop the fill to sit inside a
surface that has already chosen one; dashed is the language's "add
something" affordance.
There are three sizes because one was a fiction. A button that only comes at
20px sides is the right size for a page's main action and the wrong size for
every dense place an app has - a filter beside 11px type, a toolbar, a row of
controls in a card header - and a consumer who needs one of those spells its
own padding and font-size in utilities, at which point the button is only
borrowing the border. --sm and --xs step both numbers together, the way
.axi-table--dense does, so "the small one" is a thing you can say rather
than a pair of values you have to pick.
--icon is different in kind: not a size the language was missing but one it
had wrong. An icon-only button has no label to pad around, so the sides meant
for one produced a wide rectangle around a single glyph - which the icon page's
own "Alone in a button" example showed, uncommented, for as long as it has
existed.
--stack puts the icon over the label instead of beside it, and it is not a
style choice - it is the only thing that makes a bar of equal actions fit a
phone. Measured on the consumer that needed it: four icon+label actions side by
side want 387px of the 337px available at 393px wide, and every label is one
unbreakable word, so min-content equals max-content and flex-shrink has
nothing to give. The last action runs off the screen. Stacked, the same four
come to ~291px.
It also sets min-width: 0 on the button and on its label, because that
failure has a second half: a flex item's default min-width is its content, so
without it a button refuses to shrink below its own label even when the row is
told to divide the space, and the label's ellipsis is unreachable.
A bar of equal actions on a phone
Stacked, so four unbreakable labels fit a 393px screen<div class="axi-toolbar axi-toolbar--float axi-toolbar--nowrap" style="--axi-toolbar-pad: 8px; width: 337px">
<button class="axi-btn axi-btn--xs axi-btn--stack" style="flex: 1">
<svg class="axi-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
<span>Back</span>
</button>
<button class="axi-btn axi-btn--xs axi-btn--stack" style="flex: 1">
<svg class="axi-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 5h18M3 12h18M3 19h18"/></svg>
<span>Contents</span>
</button>
<button class="axi-btn axi-btn--xs axi-btn--stack" style="flex: 1">
<svg class="axi-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
<span>Search</span>
</button>
<button class="axi-btn axi-btn--xs axi-btn--stack" style="flex: 1">
<svg class="axi-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 19V5M5 12l7-7 7 7"/></svg>
<span>Top</span>
</button>
</div>
The four buttons
Only one of these is the primary<a class="axi-btn axi-btn--primary" href="#">Primary</a>
<a class="axi-btn" href="#">Default</a>
<a class="axi-btn axi-btn--ghost" href="#">Ghost</a>
<a class="axi-btn axi-btn--dashed" href="#">Dashed</a>
A button carrying a count
On the primary the badge inverts, because its own fill is the fill it is sitting on<button class="axi-btn axi-btn--dashed" type="button">Filters <span class="axi-badge-count">3</span></button>
<button class="axi-btn axi-btn--primary" type="button">Add <span class="axi-badge-count">3</span></button>
The three sizes, and the icon-only one
The padding and the type step together; --icon drops the sides a label was paying for<button class="axi-btn" type="button">Default</button>
<button class="axi-btn axi-btn--sm" type="button">Small</button>
<button class="axi-btn axi-btn--xs" type="button">Extra small</button>
<button class="axi-btn axi-btn--icon" type="button" aria-label="Close">
<svg class="axi-icon" aria-hidden="true"><use href="#axi-x"/></svg>
</button>
A button that has been told what it means
The ink survives the cursor - the hover brighten is a fallback, not an override<button class="axi-btn axi-btn--sm axi-ink-danger axi-edge-danger" type="button">
<svg class="axi-icon" aria-hidden="true"><use href="#axi-trash"/></svg>
Delete
</button>
Knobs
| Property | Sets | Fallback |
|---|---|---|
--axi-btn-pad | the padding inside an .axi-btn. The three named steps set it for you; reach for the knob only for a size they do not cover | 12px 20px |
--axi-btn-size | an .axi-btn's text size, which travels with its padding | 13px |