qat

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

Example.qx37 lines, 1 reactive nameOpen in the playground
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 state

Add it

shell1 line
npx qatjs add menu

A menu button: the trigger reads like a secondary button with a chevron; ↓/↑ on it open the menu. As a custom element: <ui-menu>.

Menu: props
PropTypeAttribute
labelQatNodeproperty only
itemsMenuEntry[]property only
disabledbooleanyes
size'sm' | 'md' | 'lg'yes
ariaLabelstringyes
plainbooleanyes

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

ContextMenu: props
PropTypeAttribute
itemsMenuEntry[]property only
labelstringyes

Keys

KeyDoes
↑ ↓move
Home, Endjump
Enter, Spacepick
→ ←open, close a submenu
Escclose, focus back
Shift+F10open the context menu