Chapter 03 Actions
Toggle
A button that stays pressed until it is pressed again. The label stays the same; screen readers hear 'pressed' or 'not pressed', and the look changes in fill and border, not colour alone.
import { ToggleComponent } from '@okaapi-ui/angular';With a label
Pressed is shown by the fill and a thicker border.
Not pinned
<button ui-toggle [(pressed)]="pinned">
<ui-icon name="bookmark" ui-button-start />
Pin order
</button>Icon only
With no words on it, the aria-label names it.
<button ui-toggle iconOnly aria-label="Favourite" [(pressed)]="liked">
<ui-icon name="star" />
</button>In Arabic
<button ui-toggle>تثبيت الطلب</button>When to use something else
| If you need | Use |
|---|---|
| A setting that takes effect at once, such as notifications | Switch |
| One of several views, such as grid or list | Segmented control |
| An action that happens once, such as Save | Button |
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
[(pressed)] | boolean | false | Pressed or not, two-way. |
size | 'sm' | 'md' | 'lg' | 'md' | Height and text size, as on Button. |
iconOnly | boolean | false | Square, for an icon alone. Give it an aria-label. |
disabled | boolean | false | Cannot be pressed. |
Keyboard and screen readers
| Keys | What they do |
|---|---|
| Enter or Space | Press it, or let it go. |
- Read as a toggle button, pressed or not pressed; the label never changes.