组件 侧边栏导航 玻璃质感侧边导航

玻璃质感侧边导航

一个响应式侧边导航组件,具有玻璃化设计,支持黑暗模式,并使用Tailwind CSS。具有磨砂玻璃般的半透明元素和模糊效果。

预览

HTML 代码

```html
<div class="flex h-screen bg-gray-100 dark:bg-gray-900">

    <!-- Backdrop -->
    <div id="sidebarBackdrop" class="fixed inset-0 z-10 bg-black opacity-0 md:hidden" onclick="closeSidebar()"></div>

    <!-- Sidebar -->
    <div id="sidebar" class="w-64 space-y-6 py-7 px-2 fixed inset-y-0 left-0 transform -translate-x-full md:translate-x-0 transition duration-200 ease-in-out z-20
                bg-white bg-opacity-10 dark:bg-gray-800 dark:bg-opacity-10 backdrop-filter backdrop-blur-lg dark:text-white text-gray-900">

        <!-- Logo -->
        <a class="text-white flex items-center space-x-2 px-4" href="#">
            <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.024 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.024 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.024 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.024 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.024 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.516.315 1.208.1 1.724-.51z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
            <span class="text-2xl font-extrabold">TailwindCSS</span>
        </a>

        <!-- Nav -->
        <nav>
            <a class="block py-2.5 px-4 rounded transition duration-200 hover:bg-white hover:bg-opacity-20 dark:hover:bg-gray-700 dark:hover:bg-opacity-20" href="#">Home</a>
            <a class="block py-2.5 px-4 rounded transition duration-200 hover:bg-white hover:bg-opacity-20 dark:hover:bg-gray-700 dark:hover:bg-opacity-20" href="#">About</a>
            <a class="block py-2.5 px-4 rounded transition duration-200 hover:bg-white hover:bg-opacity-20 dark:hover:bg-gray-700 dark:hover:bg-opacity-20" href="#">Services</a>
            <a class="block py-2.5 px-4 rounded transition duration-200 hover:bg-white hover:bg-opacity-20 dark:hover:bg-gray-700 dark:hover:bg-opacity-20" href="#">Contact</a>
        </nav>
    </div>

    <!-- Content -->
    <div class="flex-1 p-10 text-2xl font-bold">
        <button onclick="openSidebar()" class="md:hidden text-gray-500 dark:text-gray-400 focus:outline-none">
            <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
        </button>
        Content goes here...
    </div>

</div>

<style>
    /* For Glassmorphism effect in dark mode */
    .dark .backdrop-blur-lg {
        backdrop-filter: blur(16px);
    }

    /* For Glassmorphism effect in light mode */
    .backdrop-blur-lg {
        backdrop-filter: blur(16px);
    }
</style>

<script>
    function openSidebar() {
        document.getElementById('sidebar').classList.remove('-translate-x-full');
        document.getElementById('sidebarBackdrop').classList.remove('opacity-0');
        document.getElementById('sidebarBackdrop').classList.add('opacity-50');
    }

    function closeSidebar() {
        document.getElementById('sidebar').classList.add('-translate-x-full');
        document.getElementById('sidebarBackdrop').classList.remove('opacity-50');
        document.getElementById('sidebarBackdrop').classList.add('opacity-0');
    }
</script>
```

相关组件

侧边栏导航组件

一个响应式侧边栏导航组件,采用粗犷主义风格,完美适用于电子商务应用。它具有鲜艳的颜色,高对比度和多个互动元素,包括到不同购物类别的链接、用户账户选项,以及一个鲜艳的购物车访问按钮。该设计同样适应深色模式。

打开

侧边导航组件

为博客量身定制的侧边栏导航组件,采用 3D 元素和鲜艳的色彩设计。支持深色模式并且是响应式的,具有适合内容使用的简单布局。

打开

侧边栏导航组件

一个简单且响应迅速的侧边栏导航组件,专为仪表板设计,具有引人入胜的动画和朴实的配色方案。它支持深色模式。

打开