组件 下拉菜单 下拉菜单组件

下拉菜单组件

一个具有微交互和黑暗主题支持的响应式下拉菜单,使用Tailwind CSS构建。

预览

HTML 代码

<div class="relative w-64">
    <!-- Dropdown Button -->
    <button class="bg-gray-800 text-white font-semibold py-2 px-4 rounded inline-flex items-center focus:outline-none focus:ring-2 focus:ring-white">
        <span>Dropdown</span>
        <svg class="ml-2 w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 10l5 5 5-5" />
        </svg>
    </button>

    <!-- Dropdown Menu -->
    <div class="absolute w-full bg-gray-700 rounded-md mt-1 shadow-lg z-10 hidden group-hover:block transition-all ease-in-out duration-200 transform origin-top scale-y-0 group-hover:scale-y-100">
        <div class="py-1">
            <a href="#" class="flex items-center px-4 py-2 text-sm text-gray-300 hover:bg-gray-600 hover:text-white transition-colors duration-150">
                <img class="w-8 h-8 rounded-full mr-2" src="https://randomuser.me/api/portraits/men/1.jpg" alt="User Avatar" />
                Profile
            </a>
            <a href="#" class="flex items-center px-4 py-2 text-sm text-gray-300 hover:bg-gray-600 hover:text-white transition-colors duration-150">
                <img class="w-8 h-8 rounded-full mr-2" src="https://randomuser.me/api/portraits/women/1.jpg" alt="User Avatar" />
                Settings
            </a>
            <a href="#" class="flex items-center px-4 py-2 text-sm text-gray-300 hover:bg-gray-600 hover:text-white transition-colors duration-150">
                <img class="w-8 h-8 rounded-full mr-2" src="https://randomuser.me/api/portraits/men/2.jpg" alt="User Avatar" />
                Logout
            </a>
        </div>
    </div>
</div>

<style>
    /* Dark Mode Support */
    @media (prefers-color-scheme: dark) {
        .bg-gray-700 { background-color: #374151; }
        .text-gray-300 { color: #D1D5DB; }
        .hover\:bg-gray-600:hover { background-color: #4B5563; }
    }
</style>

相关组件

复古/怀旧下拉菜单

一个复杂的下拉菜单组件,专为电子商务设计,具有复古/复古美感,具有单色、丰富的界面和响应式设计,包括深色模式支持。

打开

下拉菜单组件

一个采用玻璃态设计风格的下拉菜单组件,具有响应效果和暗主题支持,使用Tailwind CSS。

打开

3D下拉菜单组件

一个响应式下拉菜单组件,具有鲜艳的配色方案,专为作品集展示而设计。它具有带有交互元素的 3D 设计,适用于深色模式。

打开