--- title: "dropdown-menu" description: "Click-triggered menu with outside-click and Esc to close." category: "Overlays" --- # dropdown-menu Click-triggered menu with outside-click and Esc to close. ## Installation ```bash php artisan ui:add dropdown-menu ``` ## Dependencies - composer: `gehrisandro/tailwind-merge-laravel` ## Usage ```blade Open menu {{-- align: start (default), center or end, relative to the trigger --}} Account Settings ``` ## Example The demo rendered on the docs page. ```blade Open menu ``` ## Source Copy this file to the path shown above it. `resources/views/components/ui/dropdown-menu.blade.php` ```blade @props([ 'align' => 'start', ]) @php $alignment = match ($align) { 'end' => 'right-0 origin-top-right', 'center' => 'left-1/2 -translate-x-1/2 origin-top', default => 'left-0 origin-top-left', }; $menuClasses = \TailwindMerge\Laravel\Facades\TailwindMerge::merge( 'absolute z-50 mt-2 hidden min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md', $alignment, $attributes->get('class'), ); @endphp {{-- `group/dropdown` plus data-state lets whatever you put in the trigger slot react to the open state in pure CSS, e.g. group-data-[state=open]/dropdown:rotate-180. --}}
@once @endonce ``` ## Theme tokens `--popover`, `--popover-foreground`, `--border`, `--radius` Ships its own inline