Menu
Menu, ContextMenu. They are copied into your app’s ui/ by qatjs add menu: the code is yours to edit.
Example
Right-click (or Shift+F10) here
Picked: nothing
import { ContextMenu, Menu } from './ui/menu/menu.qx'
export default function Example() {
let picked = state('')
return (
<div class="example-row">
<Menu
label="Actions"
items={[
{ group: 'Order 10482' },
{ label: 'Edit', shortcut: 'E', onSelect: () => (picked = 'edit') },
{
label: 'Move to',
items: [
{ label: 'Archive', onSelect: () => (picked = 'archive') },
{ label: 'Trash', onSelect: () => (picked = 'trash') },
],
},
'separator',
{ label: 'Cancel order', danger: true, onSelect: () => (picked = 'cancel') },
]}
/>
<ContextMenu
label="Row actions"
items={[
{ label: 'Open', onSelect: () => (picked = 'open') },
{ label: 'Copy number', onSelect: () => (picked = 'copy') },
]}
>
<p class="example-target" tabindex="0">
Right-click (or Shift+F10) here
</p>
</ContextMenu>
</div>
<p>Picked: {picked || 'nothing'}</p>
)
}picked stateAdd it
npx qatjs add menuMenu
A menu button: the trigger reads like a secondary button with a chevron; ↓/↑ on it open the menu. As a custom element: <ui-menu>.
| Prop | Type | Attribute |
|---|---|---|
label | QatNode | property only |
items | MenuEntry[] | property only |
disabled | boolean | yes |
size | 'sm' | 'md' | 'lg' | yes |
ariaLabel | string | yes |
plain | boolean | yes |
ContextMenu
The same list, opened at the pointer over `children` (or by the ContextMenu key and Shift+F10 when it has focus). As a custom element: <ui-context-menu>.
| Prop | Type | Attribute |
|---|---|---|
items | MenuEntry[] | property only |
label | string | yes |
Keys
| Key | Does |
|---|---|
| ↑ ↓ | move |
| Home, End | jump |
| Enter, Space | pick |
| → ← | open, close a submenu |
| Esc | close, focus back |
| Shift+F10 | open the context menu |