Chapter 03 Actions
Menu
A short list of actions that opens from a button, such as the actions on a row. Enter, Space or the down arrow open it, the arrow keys and typing move through it, and Escape closes it and puts focus back on the button. For choosing a value, use a select.
import { MenuComponent, MenuItemComponent, MenuTriggerDirective } from '@okaapi-ui/angular';
// On the Angular CDK menu. Add @angular/cdk/overlay-prebuilt.css.Row actions
<button ui-button variant="secondary" [uiMenuTrigger]="actions">Actions</button>
<ng-template #actions>
<ui-menu>
<button ui-menu-item (triggered)="edit()">Edit</button>
<button ui-menu-item (triggered)="duplicate()">Duplicate</button>
<button ui-menu-item disabled>Archive</button>
<div class="ui-menu__separator" role="separator"></div>
<button ui-menu-item danger (triggered)="remove()">Delete</button>
</ui-menu>
</ng-template>In Arabic
<button ui-button variant="secondary" [uiMenuTrigger]="menu">إجراءات</button>
<ng-template #menu>
<ui-menu>
<button ui-menu-item>تعديل</button>
<button ui-menu-item danger>حذف</button>
</ui-menu>
</ng-template>When to use something else
| If you need | Use |
|---|---|
| The same actions on right-click or a long press | Context menu |
| Pick a value that a form sends | Select |
| Links that go to other pages | Navigation |
| Two or three actions that fit on screen | Button group |
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
[uiMenuTrigger] | TemplateRef | — | On the button; the template holding the ui-menu. |
ui-menu | component | — | The list, inside that template. |
button[ui-menu-item] | component | — | One action. |
(triggered) | void | — | The action was chosen by click, Enter or Space. |
danger | boolean | false | Red text, for an action that destroys something. |
disabled | boolean | false | Shown, but cannot be chosen. |
Keyboard and screen readers
| Keys | What they do |
|---|---|
| Enter or Space or Down | Open the menu from its button. |
| Up or Down | Move through the actions. |
| Letters | Jump to the action that starts with them. |
| Enter or Space | Run the action. |
| Escape | Close it, and put focus back on the button. |
- Read as a menu of items; the button says it opens a menu.