Actions

Menu

A list of actions in a floating panel, with keyboard navigation, submenus, groups with headings, and checkable items. It is the panel a tk:dropdown or a tk:context opens; the account menu and tk:button.menu use it too.

Last action: —
Blade

Three actions with icons, a line, and Delete in red when highlighted. Choosing an item runs its wire:click and closes the menu. Typing a letter jumps to the next item starting with it.

From data #

Each entry is an array of tk:menu.item props and attributes; an empty entry (null) is a separator, and 'separator' => true adds one after an item. Items with href are links that navigate with wire:navigate.

Last action: —
Blade

Groups and submenus #

The group has a muted "Export" heading and lines around it. "Move to" opens a second menu beside it on hover, on click, or with Arrow Right.

Last action: —
Blade

Checkable items bound to Livewire #

A check mark shows next to the chosen sort and next to each visible column. Choosing Date sets $sort to 'date' and closes the menu; with keep-open, the column items stay open while toggled, and $columns becomes, e.g., ['email', 'phone'].

Sort: name, columns: email
Blade

In place #

A tk:menu outside a dropdown is shown in place, as a plain list of actions. Items without an icon keep the space so labels line up.

Blade

Sizes #

size sets the size of the menu and is inherited by its items.

Blade

Checkboxes and radios #

tk:menu.checkbox and tk:menu.radio also work alone, with checked; icon-on and icon-off change the icons. tk:menu.heading adds a muted heading.

Blade

Prepend and append #

The prepend and append slots add content before and after the items, such as the signed-in user or a footer note.

Blade

Customization #

Classes go to the menu box; item: reaches each item from items, and on a group heading: reaches its heading.

Blade

Reference

tk:dropdown
├── trigger
└── tk:menu
    ├── tk:menu.item
    ├── tk:menu.separator
    ├── tk:menu.group
    │   ├── tk:menu.heading
    │   └── tk:menu.item ...
    ├── tk:menu.submenu
    │   └── tk:menu.item ...
    ├── tk:menu.radio.group
    │   └── tk:menu.radio ...
    └── tk:menu.checkbox.group
        └── tk:menu.checkbox ...
Prop Type Default Description
items array null Items rendered before the slot. Each is an array of tk:menu.item props; null is a separator.
size string md xs, sm, md, lg, xl, 2xl or 3xl. Inherited by the items.
keepOpen bool false Keeps the menu open when an item is chosen.
animation string scale How the menu appears. See Dropdown, which passes it down.
Prop Type Default Description
variant string null danger highlights the item in red.
keepOpen bool false Keeps the menu open when this item is chosen.

Also accepts the element props (label, icon, badge, kbd, suffix...) and the link and action props of Element (href, route, action, disabled...).

Prop Type Default Description
label string | slot null The heading of the group, which also names it.

Takes the props of tk:menu.item (label, icon...) for its row, and keepOpen and animation for the menu it opens.

Events

Event Detail When
opened The submenu opened.
closed The submenu closed.
Prop Type Default Description
items array null The options: value => label, a list of labels (the label is the value), or arrays of item props with value.
value mixed null The initial value: one value for radios, an array for checkboxes.
label string null The heading of the group.
keepOpen bool false Keeps the menu open while items are toggled.

wire:model and x-model bind the value: the chosen value for radios, an array of values for checkboxes.

Prop Type Default Description
checked bool false The initial state, outside a group.
iconOn string mdi:check The icon shown when checked.
iconOff string null The icon shown when unchecked.

Inside a group, the item's value attribute is compared with the group's value. Also accepts the element props.

A muted heading (label and the element props), and a line, with an optional label in the middle.

Slots

Tag Slot Description
tk:menu default The items.
tk:menu prepend, append Content before and after everything else.
tk:menu.item, tk:menu.radio, tk:menu.checkbox default The item text, in place of label.
tk:menu.group, tk:menu.submenu, the choice groups default The items inside.

Events

tk:menu.submenu dispatches these on the element around the item and its menu (the container: prefix); they do not bubble.

Customization

Classes and attributes on tk:menu go to the panel's content box. On the items, they go to the item element, and the parts take the prefixes of the element props.

Prefix Tag Goes to
container: tk:menu The outer popover element around the panel's content box.
item: tk:menu, choice groups Each item rendered from items. A value set in the item itself wins; classes are added.
separator: tk:menu Each separator rendered from items.
heading:, separator-top:, separator-bottom: tk:menu.group The heading and the lines around the group.
menu:, container: tk:menu.submenu The menu it opens, and the element around both.
icon-on:, icon-off: tk:menu.radio, tk:menu.checkbox The checked and unchecked icons.
container: tk:menu.separator The element around the line.
blade

Accessibility

Follows the WAI-ARIA menu pattern: role="menu", items with role="menuitem", menuitemradio or menuitemcheckbox with aria-checked, groups with role="group" named by their heading. Only one item is in the tab order at a time.

Key Action
Arrow Down / Arrow Up Moves to the next / previous item, wrapping around and skipping disabled ones.
Home / End Moves to the first / last item; in a text field inside the menu, moves the cursor instead.
A letter Moves to the next item starting with it.
Enter, Space Chooses the focused item; on a submenu item, opens the submenu.
Arrow Right On a submenu item, opens it and focuses its first item (Arrow Left on right-to-left pages).
Arrow Left In a submenu, closes it and returns to its item (Arrow Right on right-to-left pages).
Escape Closes the innermost open menu (a submenu first) and returns focus to the item or button that opened it.

Behavior notes

  • Separators at the start or end of the menu, and two in a row, are hidden, so a list built from data can add them freely.
  • When any item has an icon, the items without one get an empty space of the same width, so the labels line up.
  • A tk:menu outside a dropdown or context is shown in place, as a plain list of actions, also inside a sidebar or an accordion.
  • Hovering or clicking a submenu item opens it; it closes shortly after the pointer leaves both the item and the submenu, with Arrow Left or with Escape.