Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 05 Choices

Checkbox

A yes or no that is saved with the form, such as accepting the terms. The native checkbox in the primary colour; the whole label is the hit area, at least 44px tall.

Use it in Angular
import { CheckboxComponent } from '@okaapi-ui/angular';
// The value is true or false. Works with formControlName, [formControl] and ngModel.
Works with

With a hint

One email per order, no adverts.

Angular
<ui-checkbox
  label="Email me about my orders"
  hint="One email per order, no adverts."
  formControlName="updates"
/>

With an error

The message is announced and tied to the checkbox, so a screen reader hears why the form did not send.

Angular
<ui-checkbox
  label="I accept the terms"
  formControlName="terms"
  [error]="form.controls.terms.invalid ? 'Accept the terms to continue' : undefined"
/>

Some of a list

indeterminate shows a dash on a parent checkbox when only some items under it are ticked.

Angular
<ui-checkbox label="All files" [indeterminate]="some()" formControlName="all" />

In Arabic

Angular
<!-- dir="rtl" on the page or any ancestor -->
<ui-checkbox label="ابعتلي إيميل عن طلباتي" />

When to use something else

If you needUse
One choice from a few optionsRadio group
A setting that takes effect at onceSwitch
Several choices from a long listCombobox or Chip input

Inputs

NameTypeDefaultWhat it does
labelstring — Required. The visible label; the whole label is the hit area.
hintstring — Help text under the checkbox, read with it.
errorstring — The translated error. Marks the checkbox invalid and announces the message.
indeterminatebooleanfalseShows a dash: some of the items under it are ticked.
testIdstring — data-testid on the input, for tests.

Keyboard and screen readers

KeysWhat they do
Space Tick or untick it.
  • The native checkbox, named by its label; the whole label is the hit area.