Last active
March 24, 2025 16:46
-
-
Save osbre/222bbc7bf09d30813e52e5f4ad2be5d6 to your computer and use it in GitHub Desktop.
Laravel Breeze HTML5 native dropdown component (no JavaScript). Remove any inner <button>'s when using.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white']) | |
@php | |
$alignmentClasses = match ($align) { | |
'left' => 'ltr:origin-top-left rtl:origin-top-right start-0', | |
'top' => 'origin-top', | |
default => 'ltr:origin-top-right rtl:origin-top-left end-0', | |
}; | |
$width = match ($width) { | |
'48' => 'w-48', | |
default => $width, | |
}; | |
@endphp | |
<details class="relative"> | |
<summary class="list-none cursor-pointer inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-hidden transition ease-in-out duration-150"> | |
{{ $trigger }} | |
</summary> | |
<div class="absolute z-50 mt-2 {{ $width }} rounded-md shadow-lg {{ $alignmentClasses }}"> | |
<div class="rounded-md ring-1 ring-black ring-opacity-5 {{ $contentClasses }}"> | |
{{ $content }} | |
</div> | |
</div> | |
</details> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To close it when clicked outside, ad this to your app.css
and add
.dropdown
to<details>