Actions

Context

A menu opened with a right-click, a long press on touch screens, or the keyboard's context menu key, placed where the user pointed. Use it for actions on an area or a row, such as copy, rename or delete, in place of the browser's own context menu.

tk:context is a tk:dropdown that opens on a context menu request instead of a click. The first element inside it is the area that opens the menu; the last one is what opens.

Right-click here
Last action: —
Blade

A dashed box. Right-clicking anywhere in it opens the menu with its top-left corner at the pointer, instead of the browser's menu, and focuses Copy. Clicking an item runs its wire:click and closes the menu. A click or a right-click outside the menu, Escape, or Tab out of it also closes it.

Rendering from data #

Each row has its own menu, acting on that file. Right-clicking a row opens the menu of that row only.

Q3 report.pdf
Team photo.png
Customers.xlsx
Last action: —
Blade

A button as the trigger #

A left click on the button does nothing here: only a right-click, a long press or the context menu key opens the menu. On a button the trigger also gets aria-haspopup and aria-expanded, which a plain div does not.

Last action: —
Blade

Any content #

The last element can be a tk:popover with any content instead of a menu. It opens at the pointer as the menu does; with nothing focusable inside, the focus moves to the panel itself, so Escape still closes it. A click inside it closes it, as a menu item does; add keep-open to the tk:popover to keep it open, for example when it holds a form.

Invoice #1024

Issued on 2026-10-01, due in 30 days.

Blade

Position and align #

position picks the side of the pointer the menu opens on and align how it lines up with it. A menu that does not fit moves to a side that does.

Opens above, to the left
Opens to the right, centered
Blade

Events #

opened and closed are dispatched on the tag itself. The component's own state is called opened, so name your counters differently.

Right-click here
Opened times, closed times
Blade

Customization #

Classes on the tag go to the inline-flex wrapper (here flex w-full to fill the row). Classes and animation for the menu go on the tk:menu.

Right-click here
Blade

Reference

tk:context
├── trigger (first element)
└── tk:menu or tk:popover (last element)

tk:context

Prop Type Default Description
position string bottom Which side of the pointer the menu opens on: bottom, top, left, right, or start / end (the side that follows the text direction).
align string start How the menu lines up with the pointer: start, end, left, right or center. start puts the pointer at the menu's leading corner.

These are the props of tk:dropdown, which receives every attribute of the tag. open defaults to context, the right click or long press on the area. When the menu does not fit on the screen in that position, another side or alignment that fits is used.

Slots

Slot Description
default Two elements: the trigger first, then the tk:menu or tk:popover it opens.

Events

Event Detail When
opened The menu opened.
closed The menu closed.

Events

Events are dispatched on the component's root, the wrapper the tag's attributes go to, and do not bubble: listen on the tag itself.

With Alpine:

blade

Calling a Livewire action:

blade

The component's own state is also named opened, so inside the tag opened means whether the menu is open: name a counter of your own differently, as above.

Customization

Classes and attributes on the tag go to the wrapper around the trigger and the menu, an inline-flex element. Classes for the menu itself go on the tk:menu or tk:popover, and its animation too (animation on tk:menu).

blade

Accessibility

The trigger is put in the tab order (tabindex="0") when it is not a link, button or form control, and gets aria-controls pointing to the menu. When it is a link, a button, a select or has a role, it also gets aria-haspopup and an aria-expanded that follows the menu. The menu is a tk:menu (role="menu" of role="menuitem" items) with its own keyboard. Opening it focuses the first item; closing it with focus inside returns focus to the trigger.

Key Action
Context menu key, Shift + F10 On the focused trigger, opens the menu below it and focuses the first item.
Arrow Down / Arrow Up Moves focus to the next / previous item, wrapping around.
Home / End Moves focus to the first / last item.
A letter Moves focus to the next item starting with it.
Enter, Space Activates the focused item.
Escape Closes the menu and returns focus to the trigger.
Tab Moves focus out and closes the menu.

Behavior notes

  • On touch screens the menu opens after a press of half a second; moving the finger more than a few pixels cancels it, and the tap that ends the press does not click the trigger. Text selection and the system's long-press callout are turned off on the wrapper on touch devices.
  • Clicking or activating an item runs it and closes the menu, unless the item or the tk:menu has keep-open. A right-click inside the menu leaves it open.
  • Right-clicking the trigger again while the menu is open moves it to the new point; the context menu key moves it back below the trigger.
  • With one tk:context inside another's trigger, a right-click on the inner area opens only the inner menu; outside it, the outer one opens.
  • Dispatching tallkit:open or tallkit:close on the trigger opens (below the trigger) or closes the menu from your own code.
  • A Livewire update keeps an open menu open, and the trigger keeps its tabindex and ARIA attributes.