Example#
Usage#
Use a checkbox for a choice that takes effect when a form is sent: agree to terms, pick the services you need. Use a Switch for a setting that applies at once.
- One or many. A single
Checkboxis a yes or no; aCheckboxGrouplets people pick any number from a list, under one legend. - Group appearance.
list(default) for long options,keysfor short ones as toggle keys that wrap,cardsfor options that need a title and a description. - Indeterminate shows a bar when some, not all, of a nested set are picked.
- The whole row is the target, at least 44 px tall on touch screens, so the 24 px box is never the only place to tap.
Anatomy#
- Box24 px, 2 px rule; checked takes the selected face and a check.
.mk-checkbox-box - LabelBody UI type; tapping it toggles the box.
.mk-checkbox-label - DescriptionOptional detail in the meta role.
.mk-checkbox-description
Volume#
Reading layer: identical at every volume.
Quiet
Studio
Press
Rave
Content#
- Labels state the choice positively: "Send me the weekly digest", not "Don't not send me emails".
- Legends ask the question once; options do not repeat it.
- Terms and consent link the document and name it: "I agree to the [privacy policy]".
Do and don't#
Do
Don't
Accessibility#
- Each box is native: Space toggles it and the whole label row is the target (44 px tall on touch screens).
- Checked boxes show a check on the selected face; selected keys and cards add a heavier ink rule and a check, never colour alone.
indeterminatesets the native mixed state, so it needs a client caller.
| Keys | What happens |
|---|---|
| Tab | Moves focus to the box (each box is its own stop) |
| Space | Checks or clears the box |
The colour pairs it prints, with their contrast on both papers:
| Text | Surface | Role | Bone | Night |
|---|---|---|---|---|
--mk-ink-rule | --mk-paper | ui | 3.27:1 · Lc 56.5, passes | 3.65:1 · Lc 25.6, passes |
--mk-ink-rule | --mk-paper-sunken | ui | 3.01:1 · Lc 51.2, passes | 3.49:1 · Lc 25.2, passes |
--mk-ink-rule | --mk-paper-plate | ui | 3.65:1 · Lc 64.1, passes | 3.38:1 · Lc 24.8, passes |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
label required | ReactNode | none | Required: the visible label. |
description | ReactNode | none | |
indeterminate | boolean | none | The mixed state: a 3 px bar. It sets the IDL `indeterminate` through a ref, so it needs a client caller. |
className | string | none | Lands on the row (`label.mk-checkbox`). |
style | CSSProperties | none | Lands on the row. |
Tokens#
System tokens (40)
--mk-border--mk-border-thick--mk-control--mk-control-rule--mk-disabled--mk-dur-press--mk-ease-out--mk-focus--mk-font-text--mk-on-control--mk-on-selected--mk-radius-control--mk-rule--mk-selected--mk-space-1--mk-space-2--mk-space-3--mk-space-4--mk-space-5--mk-space-6--mk-surface-raised--mk-target-min--mk-target-touch--mk-text--mk-text-2--mk-text-disabled--mk-type-body-ui-leading--mk-type-body-ui-size--mk-type-body-ui-tracking--mk-type-body-ui-weight--mk-type-field-label-leading--mk-type-field-label-size--mk-type-field-label-weight--mk-type-meta-leading--mk-type-meta-size--mk-type-meta-weight--mk-type-row-title-leading--mk-type-row-title-size--mk-type-row-title-tracking--mk-type-row-title-weight
Its own properties (2)
--mk-checkbox-box--mk-checkbox-key-edge
Changelog#
Arrived in 0.1.0.
- The reading layer's controls, overlays, forms and visitor prefs (P2-T1 to P2-T5): every Button is the comic hit key, with IconButton, Link and Tooltip; Input, Textarea, Select, Checkbox and CheckboxGroup, Radio and RadioGroup, Switch, Slider with the ruler, RulerReadout and SegmentedControl; Dialog, Drawer, NavSheet, Tabs, Disclosure, Faq and faqJsonLd on Base UI 1.9 where the platform falls short; Field, Fieldset, Form with the site's inline validation, ErrorSummary, Callout, Honeypot, FormTimestamp and QuoteForm; PrefsScript under 1 KB, usePref and setPref with cross-tab sync, ThemeToggle and the visitor VolumeDial; VisuallyHidden.