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

Chapter 05 Choices

Switch

An on or off setting that takes effect at once, with no save button. Screen readers say on and off, and the knob's side shows the state, so it never depends on colour. For a choice saved with a form, use a checkbox.

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

Settings

A message to your phone when the driver is near.

Angular
<ui-switch
  label="Order updates"
  hint="A message to your phone when the driver is near."
  formControlName="updates"
/>
<ui-switch label="Offers" formControlName="offers" />

In Arabic

Angular
<ui-switch label="تحديثات الطلب" formControlName="updates" />

When to use something else

If you needUse
A choice sent with a formCheckbox
A pressed state in a toolbar, such as boldToggle

Inputs

NameTypeDefaultWhat it does
labelstring — Required. The setting it turns on.
hintstring — Help text under it, read with the switch.
testIdstring — data-testid on the input, for tests.

Keyboard and screen readers

KeysWhat they do
Space Turn it on or off.
  • A checkbox with the switch role, so screen readers say on and off.