Actions

Dropdown

A button that opens a floating panel next to it: a menu of actions, or a popover with any content. Use it for actions that do not need to be on screen all the time, such as the options of a row or of a page header.

The first element inside tk:dropdown is the trigger and the last one is the panel that opens. tk:dropdown.button is a tk:button with a chevron that turns while the panel is open; any focusable element works as the trigger.

Last action: —
Blade

An "Options" button with a chevron. Clicking it opens the menu under the button, aligned to its start edge, and the chevron turns upside down. Clicking an item runs its wire:click and closes the menu; a click outside, Escape, or Tab out of the menu also closes it.

Opening on hover #

The menu opens while the pointer is over the button or over the menu, aligned to the button's end edge, and closes shortly after the pointer leaves both. Focusing the button with the keyboard also opens it. On touch screens, where there is no hover, it opens on tap like the default.

Blade

Any content in the panel #

A panel with a checkbox and a select. keep-open keeps it open while the user works inside it; without it, the first click inside closes the panel. A click outside or Escape closes it.

Only active: no, sort: name
Blade

A trigger of your own #

The avatar opens the menu above it. The avatar renders a button, so it gets aria-haspopup, aria-expanded and aria-controls from the dropdown; a trigger that is not a link, button, select or an element with a role gets only aria-controls.

Last action: —
Blade

Position and align #

position picks the side of the trigger the panel opens on, and align how it lines up with it. With no room, the panel flips to the other side.

Blade

Button arrow and animation #

arrow changes the chevron (or removes it with false), animate bound to false keeps it still, and animation sets how the panel appears.

Blade

Rows from data #

One dropdown per row with @foreach; each menu acts on its own customer.

Ana Souza
Bruno Lima
Carla Mendes
Last action: —
Blade

Events #

opened and closed are dispatched on the tag. Keep your state on a parent, under a name other than open; @opened can also call a Livewire action.

Open: , loaded 0 times
Blade

Customization #

Classes on tk:dropdown go to its inline-flex wrapper; the trigger and the panel are your own tags, so style them directly.

Blade

Reference

tk:dropdown
├── trigger (first element, usually tk:dropdown.button)
└── tk:menu or tk:popover (last element)
Prop Type Default Description
open string click What opens the panel: click, hover, or context (a right-click or long press; see Context).
position string bottom Side of the trigger the panel opens on: top, bottom, left, right, or start / end (the side that follows the text direction). When there is no room, it flips to the other side.
align string start How the panel lines up with the trigger: start, center, end, left or right. start and end follow the text direction.
animation string scale How the panel appears: fade, zoom, slide, slide-up, slide-down, slide-left, slide-right, the last four also with -full (slide-up-full...), or none. By default it grows from half its size. Passed to the tk:menu or tk:popover inside.

Slots

Slot Description
default The trigger first and the panel last.

Events

Event Detail When
opened The panel opened.
closed The panel closed.
Prop Type Default Description
arrow string | false mdi:chevron-down The icon after the label. false removes it.
animate bool true Turns the arrow upside down while the panel is open. false keeps it still.

Also accepts the element props (label, icon, badge...) and every tk:button attribute (variant, size...). It takes no slot content: the text goes in label.

Events

Events are dispatched on the tk:dropdown element and do not bubble: listen on the tag itself.

With Alpine:

blade

The tag already has its own x-data, so the state lives on a parent element, under a name other than open, which is the dropdown's method.

Calling a Livewire action:

blade

Dispatching tallkit:open or tallkit:close on the trigger opens or closes the panel from your own code.

Customization

Classes and attributes on tk:dropdown go to its wrapper, an inline-flex <div>. The trigger and the panel are your own tags, so their classes and attributes are set on them directly.

blade

Accessibility

Follows the WAI-ARIA menu button pattern when the panel is a tk:menu. The trigger gets aria-controls pointing to the panel and aria-expanded, which follows the panel's state, plus aria-haspopup when the panel is a menu, listbox or dialog. A panel with a plain form gets no aria-haspopup, so it is not announced as a menu.

Key Action
Enter, Space Opens the menu and focuses its first item.
Arrow Down / Arrow Up On the trigger, opens the menu and focuses the first / last item. With the menu already open (after a mouse click), moves focus into it.
Escape Closes the panel and returns focus to the trigger.
Tab Leaving the trigger and the panel closes it.

The keys inside the menu are those of tk:menu.

Behavior notes

  • A mouse click opens a menu without moving focus into it; a click from the keyboard (Enter or Space) focuses the first item.
  • Any click inside the panel closes it, which is what a menu wants. For a panel the user works in, set keep-open on the tk:popover (or on tk:menu), or data-keep-open on one element inside it to keep the panel open only for clicks there.
  • The panel is a browser popover in the top layer, so overflow: hidden on a parent does not clip it, and it follows the trigger on scroll and resize.
  • The wrapper has wire:ignore.self: a Livewire update keeps the panel open and the trigger's ARIA attributes as they are.
  • A panel inside a tk:modal closes when the modal closes, also when the modal is closed by code.
  • When the trigger is a text field, a click opens the panel and leaves the focus in the field, so the user can keep typing; Arrow Down moves it into the panel.