Component
Click Menu
Click-triggered dropdown menu with embedded profile card and user actions.
- Component
- Tailwind
- HTML
- MIT
Preview
Live component
9:41 100%
devsnips.dev/library/tailwind/components/dropdowns/click-menu/ fluid · no fixed width 100%
Install
Add to your project
npx devsnips add Tailwind/Components/Dropdowns/click-menu Tailwind/Components/Dropdowns/click-menu <!-- Click Menu -->
<div class="relative inline-block">
<button
id="click-trigger"
class="inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors"
onclick="toggleClickMenu()"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"></path>
</svg>
<span>Click Menu</span>
</button>
<div
id="click-dropdown"
class="hidden absolute right-0 z-20 mt-2 w-64 bg-white rounded-xl shadow-xl border border-gray-200 overflow-hidden"
>
<div class="p-4">
<div class="flex items-center gap-3 p-3 bg-gray-50 rounded-lg mb-4">
<img
src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=80&h=80&fit=crop&crop=faces"
alt="User avatar"
class="w-10 h-10 rounded-full object-cover"
/>
<div>
<p class="text-sm font-semibold text-gray-900">Alex Chen</p>
<p class="text-xs text-gray-500">Premium Member</p>
</div>
</div>
<div class="space-y-1">
<button class="w-full flex items-center gap-3 px-3 py-2.5 text-sm text-gray-700 rounded-lg hover:bg-blue-50 hover:text-blue-600 transition-colors">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
</svg>
<span>Account Settings</span>
</button>
<button class="w-full flex items-center gap-3 px-3 py-2.5 text-sm text-gray-700 rounded-lg hover:bg-blue-50 hover:text-blue-600 transition-colors">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
</svg>
<span>Profile</span>
</button>
<button class="w-full flex items-center gap-3 px-3 py-2.5 text-sm text-gray-700 rounded-lg hover:bg-blue-50 hover:text-blue-600 transition-colors">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"></path>
</svg>
<span>Saved Items</span>
</button>
</div>
</div>
<div class="border-t border-gray-100 p-4">
<button class="w-full flex items-center gap-3 px-3 py-2.5 text-sm text-red-600 rounded-lg hover:bg-red-50 transition-colors">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"></path>
</svg>
<span>Sign Out</span>
</button>
</div>
</div>
</div>
<script>
function toggleClickMenu() {
document.getElementById('click-dropdown').classList.toggle('hidden');
}
document.addEventListener('click', function(event) {
const container = document.querySelector('.relative.inline-block');
if (!container.contains(event.target)) {
document.getElementById('click-dropdown').classList.add('hidden');
}
});
</script> # Click Menu
Click-triggered dropdown menu.
## Preview
Open `preview.html` for a standalone demonstration.
## Features
- Click to open
- Menu item list
## Usage
```bash
npx devsnips add Tailwind/Components/Dropdowns/click-menu
```
Copy from `code.html`.
## Customization
- Trigger and menu surface styles
## Accessibility
- Keyboard operability and focus handling recommended
## Dependencies
- Tailwind CSS; small JS if script is present
## File Structure
- `code.html` · `preview.html` · `metadata.json` · `README.md` 77 lines UTF-8 · LF · Spaces: 2
Continue browsing