Guides
Navigation
Feedback
Overlays
Layout
Data Display
Forms
.md

Overlays

dropdown-menu

Click-triggered menu with outside-click and Esc to close.

Installation

php artisan ui:add dropdown-menu

Usage

<x-ui.dropdown-menu>
    <x-slot:trigger>
        <x-ui.button variant="outline">Open menu</x-ui.button>
    </x-slot:trigger>

    <button role="menuitem"
        class="block w-full rounded-sm px-3 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground">
        Profile
    </button>
</x-ui.dropdown-menu>

{{-- align: start (default), center or end, relative to the trigger --}}
<x-ui.dropdown-menu align="end">
    <x-slot:trigger>
        <x-ui.button variant="ghost">Account</x-ui.button>
    </x-slot:trigger>

    <a href="/settings" role="menuitem"
        class="block rounded-sm px-3 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground">
        Settings
    </a>
</x-ui.dropdown-menu>

Ships its own inline <script>; no JS dependencies. `trigger` slot opens it; put menu items (role=menuitem) in the default slot. align: start|center|end. The root exposes group/dropdown + data-state so trigger markup can style itself with group-data-[state=open]/dropdown:*.

Props

Every prop with its default. Pass any of them as attributes, using : to bind a PHP value.

@props([
    'align' => 'start',
])