Field, input and switch
Labelled inputs and switches for Settings, the profile editor and setup.
HTML
<div class="bm-stage">
<section class="bm-tile" style="width:366px">
<label class="bm-field"><span class="bm-field__label">Machine name</span><input class="bm-input" value="Kitchen Gaggia" aria-describedby="h1"><p class="bm-help" id="h1">Shown in the browser tab and on the Wi-Fi setup page.</p></label>
<div class="bm-field"><label class="bm-field__label" for="pw">Wi-Fi password</label><span class="bm-inputwrap"><input class="bm-input bm-input--reveal" id="pw" type="password" autocomplete="current-password" aria-describedby="h2"><button class="bm-btn bm-btn--icon bm-btn--quiet" type="button" data-reveal="pw" aria-pressed="false" aria-label="Show password"><span data-icon="eye"></span></button></span><p class="bm-help" id="h2">Leave blank to keep the saved one.</p></div>
<label class="bm-field"><span class="bm-field__label">Notes<span class="bm-field__opt">Optional</span></span><textarea class="bm-textarea" aria-describedby="h3">Light roast, ground at 2.4.</textarea><span class="bm-field__count" id="h3">27 / 120</span></label>
</section>
<section class="bm-tile" style="width:366px">
<label class="bm-field"><span class="bm-field__label">Profile name</span><input class="bm-input" value="First" aria-invalid="true" aria-describedby="e1"><span class="bm-field__msg bm-field__msg--error" id="e1"><span data-icon="circle-alert" data-size="14"></span>Another profile is called First. Choose a different name.</span></label>
<label class="bm-field"><span class="bm-field__label">Controller address</span><input class="bm-input" placeholder="192.168.1.20" inputmode="decimal" aria-describedby="w1"><span class="bm-field__msg bm-field__msg--warning" id="w1"><span data-icon="triangle-alert" data-size="14"></span>Empty means the machine searches for it at each start.</span></label>
<label class="bm-field"><span class="bm-field__label">Network password</span><input class="bm-input" type="password" value="hunter2hunter2" aria-describedby="s1"><span class="bm-field__msg bm-field__msg--success" id="s1"><span data-icon="check" data-size="14"></span>Connected to Home 5G.</span></label>
<label class="bm-field"><span class="bm-field__label">Firmware channel</span><input class="bm-input" value="Stable" disabled aria-describedby="d1"><p class="bm-help" id="d1">Set by the controller while it updates.</p></label>
</section>
<section class="bm-tile" style="width:296px">
<div class="bm-setting"><span><span class="bm-field__label" id="sw1">Wake on a schedule</span><p class="bm-help">Hot before your first coffee.</p></span><button class="bm-switch" role="switch" aria-checked="true" aria-labelledby="sw1"></button></div>
<div class="bm-setting"><span><span class="bm-field__label" id="sw2">Smart grind</span><p class="bm-help">Stops the grinder by weight.</p></span><button class="bm-switch" role="switch" aria-checked="false" aria-labelledby="sw2"></button></div>
<div class="bm-setting"><span><span class="bm-field__label" id="sw3" style="color:var(--ink-faint)">Stop by weight</span><p class="bm-help">Connect a scale to use this.</p></span><button class="bm-switch" role="switch" aria-checked="false" aria-labelledby="sw3" disabled></button></div>
</section>
</div>- Label above in
label, sentence case; help below inbody-sm, one sentence. - Inputs are 44 px,
surface-2, with aline-stronghairline: the border is what shows where to type, becausesurface-2on a tile is only 1.1:1. - A Switch is for something that is on or off and applies at once. On is
ink; off isline-strong. Put its label and help on the left, the switch on the right. - Instructions go in help text, where they stay visible while you type: "Leave blank to keep the saved one." A placeholder is optional, shows only an example of the format ("192.168.1.20"), is set in
ink-muted, and is never the only place a rule is written.
Anatomy
label.bm-field stacks, space-2 apart: .bm-field__label (with .bm-field__opt for "Optional" at the right), the control, then .bm-help or a .bm-field__msg. Controls are .bm-input, .bm-textarea (88 px or taller), .bm-select and the number field; see Select and NumberField. A control with something inside it (a unit, a chevron, a show-password button) sits in .bm-inputwrap.
States
| State | Border | Fill | Text | Message |
|---|---|---|---|---|
| Rest | line-strong | surface-2 | ink | help in ink-muted |
| Hover | ink | |||
| Focus | line-strong and the focus ring | |||
Error (aria-invalid="true") | danger | circle-alert and a sentence in danger; it replaces the help | ||
| Warning | line-strong | triangle-alert and a sentence in warning, when the value is allowed but unusual | ||
| Valid | line-strong | check and a short confirmation in success, only after a check that takes time (a Wi-Fi password, a name already taken) | ||
| Disabled | line | surface-1 | ink-faint | help says why |
A message always has its glyph and its words; the border colour is never the only sign. Validate when the field loses focus and again on submit, not on every key. On submit, move focus to the first field with an error.
Switch
48 by 28 px drawn, with a hit area 44 px tall. Off: line-strong track, surface-2 knob. On: ink track, on-ink knob. Hover steps the track to ink-muted or ink-hover. Disabled: track, and the label turns ink-faint. The knob travels in duration-base; nothing else moves.
Content
- Label: a noun phrase of at most 28 characters, with no colon: "Machine name", "Standby after".
- Help: one sentence. Mark the few optional fields "Optional" rather than starring the required ones.
- Error: what is wrong and how to fix it, in one sentence, without "invalid" or "error": "Enter 80 to 100 °C." "That password did not work. Check it and try again."
- A counter (
.bm-field__count, "12 / 24") appears only where a limit exists.
Keyboard and screen reader
- The
labelwraps or points to its control. Help and messages are linked witharia-describedby, and an error also setsaria-invalid="true". - Give Wi-Fi and account fields their
autocompletevalues (current-password,offfor a network name) and the rightinputmode. - The show-password button is a
bm-btn--quietwitharia-pressedand a label that says what pressing does: "Show password", "Hide password". - A Switch is
button role="switch"witharia-checked, named by its visible label througharia-labelledby. Space and Enter toggle it. The change applies at once; no Save.