Dropdown
Alpine.js で開閉する汎用ドロップダウン。trigger を slot で差し替え可能、label prop で簡易ボタン化も可能。position (bottom-end default / bottom-start / top-end / top-start)・size (sm/md/lg)・width (任意の Tailwind w-* class) の 3 props。menu の中身は自由スロット — リンクでもボタンでも何でも入る。
最小: label でボタン化
<x-dropdown label="Menu">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Profile</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Settings</a>
<x-menu-divider />
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-error">Log out</a>
</x-dropdown>
position — bottom-end / bottom-start / top-end / top-start
<x-dropdown label="bottom-end" position="bottom-end">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Opens down, right-aligned</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Item 2</a>
</x-dropdown>
<x-dropdown label="bottom-start" position="bottom-start">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Opens down, left-aligned</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Item 2</a>
</x-dropdown>
<x-dropdown label="top-end" position="top-end">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Opens up, right-aligned</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Item 2</a>
</x-dropdown>
<x-dropdown label="top-start" position="top-start">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Opens up, left-aligned</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Item 2</a>
</x-dropdown>
size — sm / md / lg
<x-dropdown label="sm" size="sm">
<a href="#" class="block px-3 py-1.5 text-xs hover:bg-base-200 text-base-content">Small item 1</a>
<a href="#" class="block px-3 py-1.5 text-xs hover:bg-base-200 text-base-content">Small item 2</a>
</x-dropdown>
<x-dropdown label="md (default)" size="md">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Standard item 1</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Standard item 2</a>
</x-dropdown>
<x-dropdown label="lg" size="lg">
<a href="#" class="block px-5 py-2.5 text-base hover:bg-base-200 text-base-content">Large item 1</a>
<a href="#" class="block px-5 py-2.5 text-base hover:bg-base-200 text-base-content">Large item 2</a>
</x-dropdown>
width — w-40 / w-52 (default) / w-72 / w-96
<x-dropdown label="w-40" width="w-40">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Narrow</a>
</x-dropdown>
<x-dropdown label="w-52 (default)" width="w-52">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Standard</a>
</x-dropdown>
<x-dropdown label="w-72" width="w-72">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Wide</a>
</x-dropdown>
<x-dropdown label="w-96" width="w-96">
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Extra wide</a>
</x-dropdown>
trigger を自前で組む (アバター・アイコンボタン等)
<x-dropdown>
<x-slot:trigger>
<button class="inline-flex items-center gap-2 px-3 py-2 rounded-[var(--radius-field)] bg-primary text-primary-content text-sm font-medium">
<x-i type="hamburger-menu" variant="linear" class="w-4 h-4" />
Actions
</button>
</x-slot:trigger>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Edit</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Duplicate</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-error">Delete</a>
</x-dropdown>
<x-dropdown position="bottom-start">
<x-slot:trigger>
<div class="inline-flex items-center justify-center w-10 h-10 rounded-full bg-base-300 text-base-content font-semibold cursor-pointer">YT</div>
</x-slot:trigger>
<div class="px-4 py-2 border-b border-base-300">
<div class="text-sm font-medium text-base-content">Yamada Taro</div>
<div class="text-xs text-base-content/60">taro@example.com</div>
</div>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Profile</a>
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-base-content">Account settings</a>
<x-menu-divider />
<a href="#" class="block px-4 py-2 text-sm hover:bg-base-200 text-error">Log out</a>
</x-dropdown>
menu-divider でグループ分け (区切り線がパネル両端まで届く)
<x-dropdown label="Account">
<x-menu-item icon="user">Profile</x-menu-item>
<x-menu-item icon="settings">Settings</x-menu-item>
<x-menu-divider />
<x-menu-item icon="logout">Sign out</x-menu-item>
</x-dropdown>
block: 親幅いっぱいに広げる (サイドバー下部・フォーム行)
<div class="w-64 rounded-[var(--radius-box)] border border-dashed border-base-300 p-sm">
<x-dropdown label="Workspace" block>
<x-menu-item icon="user">Profile</x-menu-item>
<x-menu-item icon="settings">Settings</x-menu-item>
<x-menu-divider />
<x-menu-item icon="logout">Sign out</x-menu-item>
</x-dropdown>
</div>
<div class="w-64 rounded-[var(--radius-box)] border border-dashed border-base-300 p-sm">
<x-dropdown label="Workspace (top-start)" position="top-start" block>
<x-menu-item icon="user">Profile</x-menu-item>
<x-menu-item icon="settings">Settings</x-menu-item>
<x-menu-divider />
<x-menu-item icon="logout">Sign out</x-menu-item>
</x-dropdown>
</div>