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.
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.
<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
<ui-switch label="تحديثات الطلب" formControlName="updates" />When to use something else
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
label | string | — | Required. The setting it turns on. |
hint | string | — | Help text under it, read with the switch. |
testId | string | — | data-testid on the input, for tests. |
Keyboard and screen readers
| Keys | What they do |
|---|---|
| Space | Turn it on or off. |
- A checkbox with the switch role, so screen readers say on and off.