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

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.

Use it in Angular
import { ToggleComponent } from '@okaapi-ui/angular';

With a label

Pressed is shown by the fill and a thicker border.

Not pinned

Angular
<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.

Angular
<button ui-toggle iconOnly aria-label="Favourite" [(pressed)]="liked">
  <ui-icon name="star" />
</button>

In Arabic

Angular
<button ui-toggle>تثبيت الطلب</button>

When to use something else

If you needUse
A setting that takes effect at once, such as notificationsSwitch
One of several views, such as grid or listSegmented control
An action that happens once, such as SaveButton

Inputs

NameTypeDefaultWhat it does
[(pressed)]booleanfalsePressed or not, two-way.
size'sm' | 'md' | 'lg''md'Height and text size, as on Button.
iconOnlybooleanfalseSquare, for an icon alone. Give it an aria-label.
disabledbooleanfalseCannot be pressed.

Keyboard and screen readers

KeysWhat they do
Enter or Space Press it, or let it go.
  • Read as a toggle button, pressed or not pressed; the label never changes.