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.
import { ButtonComponent } from '@okaapi-ui/angular';Variants
One primary action per screen. Danger is for actions that destroy something.
<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.
<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.
<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.
<button ui-button [loading]="saving()" (click)="save()">Save changes</button>Disabled
<button ui-button disabled>Save</button>In Arabic
<!-- 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 need | Use |
|---|---|
| Go to another page | A link (a href) |
| A state that stays on or off, such as bold | Toggle |
| Several actions that belong together | Button group |
| More actions than fit, behind one button | Menu |
Inputs
| Name | Type | Default | What 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. |
loading | boolean | false | Disables the button, sets aria-busy and shows a spinner. |
iconOnly | boolean | false | Square 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). |
disabled | boolean | false | Disables the button. |
Keyboard and screen readers
| Keys | What 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.