Checkbox
A box that toggles a check mark on tap, with its label beside it.
Installation
Usage
src/app/app.ts
- The whole row toggles it, label included. On a phone the words are the easier target.
- The row is 44px tall at least, and a long label wraps beside the box.
- The check mark pops in and out when the state changes.
Without a label
- Without a
label, the checkbox is only the box: 22px, lined up with what's around it. - Its tap area still reaches 48px across, a comfortable size for a finger, without taking that room in the layout.
- Give it an
accessibility-label, so a screen reader can name it.
Disabled
A disabled checkbox dims and ignores taps.
Listen without a signal
changed emits the new state after each tap.
Forms
checked is a model(), so it works with every Angular forms API:
A tap marks the field touched, so its error can show. UiCheckbox implements Signal Forms' FormCheckboxControl. See Forms.
API
UiCheckbox
UiCheckbox also has a public toggle() method, which does nothing while disabled.
Accessibility
- A screen reader reads the checkbox as one button, named by its
label(oraccessibility-label), with the value "Checked" or "Unchecked", in the words ofprovideAccessibilityWords()when the app gives its own. - A disabled checkbox is read as dimmed.
Related
- Switch: an on/off control for settings
- Radio Group: pick one of several options
- Label: a label of your own, beside a checkbox without one
