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

Chapter 03 Actions

Button

Styles the native button, so it keeps everything the browser gives a button: focus, Enter and Space, form submit. Nine variants, three sizes, icons, and hover, press and focus feedback.

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

Variants

One primary action per screen. Danger is for actions that destroy something.

Angular
<button ui-button>Save</button>
<button ui-button variant="secondary">Cancel</button>
<button ui-button variant="ghost">Skip</button>
<button ui-button variant="danger">Delete</button>
<button ui-button variant="success">Approve</button>
<button ui-button variant="warning">Review</button>
<button ui-button variant="outline">Edit</button>
<button ui-button variant="soft">Details</button>
<button ui-button variant="link">Learn more</button>

Icons

Icons before or after the label are hidden from screen readers. An icon-only button needs an aria-label.

Angular
<button ui-button>
  <ui-icon ui-button-start name="plus" />
  New file
</button>
<button ui-button variant="secondary">
  Next
  <ui-icon ui-button-end name="arrow-right" />
</button>
<button ui-button variant="outline" iconOnly aria-label="Search">
  <ui-icon name="search" />
</button>

Sizes

Even the small size stays 44 pixels high, the smallest comfortable touch target.

Angular
<button ui-button size="sm">Small</button>
<button ui-button>Medium</button>
<button ui-button size="lg">Large</button>

Loading

Disables the button, marks it busy for screen readers and shows a spinner.

Angular
<button ui-button [loading]="saving()" (click)="save()">Save changes</button>

Disabled

Angular
<button ui-button disabled>Save</button>

In Arabic

Angular
<!-- dir="rtl" on the page or any ancestor -->
<button ui-button>حفظ</button>
<button ui-button variant="secondary">إلغاء</button>

When to use something else

If you needUse
Go to another page A link (a href)
A state that stays on or off, such as boldToggle
Several actions that belong togetherButton group
More actions than fit, behind one buttonMenu

Inputs

NameTypeDefaultWhat it does
variant'primary' | 'secondary' | 'ghost' | 'danger' | 'outline' | 'soft' | 'link' | 'success' | 'warning''primary'How much the button stands out.
size'sm' | 'md' | 'lg''md'Padding and text size. Height never drops under 44 pixels.
loadingbooleanfalseDisables the button, sets aria-busy and shows a spinner.
iconOnlybooleanfalseSquare button for a lone icon. Add an aria-label.
[ui-button-start] / [ui-button-end]content slot — Put an icon before or after the label. Hidden while loading (start).
disabledbooleanfalseDisables the button.

Keyboard and screen readers

KeysWhat they do
Enter or Space Press the button.
  • A native button, so its role, focus and form submit come from the browser.
  • A button with only an icon needs a label in words for screen readers.