Published on

How To Create A Mini Column Sidebar With Tailwind CSS In 5 Easy Steps

Tags
Mini column sidebar

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.

The description of Mini column sidebar ui component

Responsive mini column sidebar layout with dark & light mode

Why use Tailwind CSS to make a Mini column sidebar ui component?

  • It can make the building process of Mini column sidebar ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in Mini column sidebar component file.

The preview of Mini column sidebar ui component

Free download of the Mini column sidebar's source code

The source code of Mini column sidebar ui component

<style>
/* This example part of kwd-dashboard see https://kamona-wd.github.io/kwd-dashboard/ */
/* So here we will write some classes to simulate dark mode and some of tailwind css config in our project */
:root {
--light: #edf2f9;
--dark: #152e4d;
--darker: #12263f;
}

.dark .dark\:text-light {
    color: var(--light);
}

.dark .dark\:bg-dark {
    background-color: var(--dark);
}

.dark .dark\:bg-darker {
    background-color: var(--darker);
}

.dark .dark\:text-gray-300 {
    color: #d1d5db;
}

.dark .dark\:text-indigo-700 {
c   olor: #4338ca;
}

.dark .dark\:text-indigo-500 {
    color: #6366f1;
}

.dark .dark\:text-indigo-100 {
    color: #e0e7ff;
}

.dark .dark\:hover\:text-light:hover {
    color: var(--light);
}

.dark .dark\:border-indigo-800 {
    border-color: #3730a3;
}

.dark .dark\:border-indigo-700 {
    border-color: #4338ca;
}

.dark .dark\:bg-indigo-600 {
    background-color: #4f46e5;
}

.dark .dark\:hover\:bg-indigo-600:hover {
    background-color: #4f46e5;
}

.dark .dark\:border-indigo-500 {
    border-color: #6366f1;
}

.dark .group:hover .dark\:group-hover\:text-indigo-400 {
    color: #818cf8;
}

.hover\:overflow-y-auto:hover {
    overflow-y: auto;
}
</style>

<div
    x-data="setup()"
    x-init="$refs.loading.classList.add('hidden')"
    :class="{ 'dark': isDark}"
    @resize.window="watchScreen()"
>
    <div class="flex h-screen antialiased text-gray-900 bg-gray-100 dark:bg-dark dark:text-light">
    <!-- Loading screen -->
    <div
        x-ref="loading"
        class="fixed inset-0 z-50 flex items-center justify-center text-2xl font-semibold text-white bg-indigo-800"
    >
        Loading.....
    </div>

    <!-- Sidebar first column -->
    <!-- Backdrop -->
    <div
        x-show="isSidebarOpen"
        @click="isSidebarOpen = false"
        class="fixed inset-0 z-10 bg-indigo-800 md:hidden"
        style="opacity: 0.5"
        aria-hidden="true"
    ></div>

    <aside
        x-show="isSidebarOpen"
        x-transition:enter="transition-all transform duration-300 ease-in-out"
        x-transition:enter-start="-translate-x-full opacity-0"
        x-transition:enter-end="translate-x-0 opacity-100"
        x-transition:leave="transition-all transform duration-300 ease-in-out"
        x-transition:leave-start="translate-x-0 opacity-100"
        x-transition:leave-end="-translate-x-full opacity-0"
        x-ref="sidebar"
        @keydown.escape="window.innerWidth <= 768 ? isSidebarOpen = false : ''"
        tabindex="-1"
        class="fixed inset-y-0 z-10 flex flex-shrink-0 bg-white border-r md:static dark:border-indigo-800 dark:bg-darker focus:outline-none"
    >
        <!-- Mini column -->
        <nav class="flex flex-col flex-shrink-0 h-full px-2 py-4 border-r dark:border-indigo-800">
        <!-- Brand -->
        <div class="flex-shrink-0">
            <a
            href="https://kamona-wd.github.io/kwd-dashboard/"
            class="inline-block text-xl font-bold tracking-wider text-indigo-700 uppercase dark:text-light"
            >
            K-WD
            </a>
        </div>
        <div class="flex flex-col items-center justify-center flex-1 space-y-4">
            <!-- Home link -->
            <!-- Active classes "bg-indigo-600 text-white" -->
            <!-- inActive classes "bg-indigo-50 text-indigo-400" -->
            <a
            href="#"
            class="p-2 text-white transition-colors duration-200 bg-indigo-600 rounded-full hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:bg-indigo-100 dark:focus:bg-indigo-700 focus:ring-indigo-800"
            >
            <span class="sr-only">Home</span>
            <svg
                class="w-7 h-7"
                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="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"
                />
            </svg>
            </a>
            <!-- Message link -->
            <!-- Active classes "bg-indigo-600 text-white" -->
            <!-- inActive classes "bg-indigo-50 text-indigo-400" -->
            <a
            href="#"
            class="p-2 text-indigo-400 transition-colors duration-200 rounded-full bg-indigo-50 hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:bg-indigo-100 dark:focus:bg-indigo-700 focus:ring-indigo-800"
            >
            <span class="sr-only">Messages</span>
            <svg
                class="w-7 h-7"
                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 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"
                />
            </svg>
            </a>
            <!-- Another link -->
            <!-- Active classes "bg-indigo-600 text-white" -->
            <!-- inActive classes "bg-indigo-50 text-indigo-400" -->
            <a
            href="#"
            class="p-2 text-indigo-400 transition-colors duration-200 rounded-full bg-indigo-50 hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:bg-indigo-100 dark:focus:bg-indigo-700 focus:ring-indigo-800"
            >
            <span class="sr-only">Another Link</span>
            <svg
                class="w-7 h-7"
                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="M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z"
                />
            </svg>
            </a>
            <!-- Users link -->
            <!-- Active classes "bg-indigo-600 text-white" -->
            <!-- inActive classes "bg-indigo-50 text-indigo-400" -->
            <a
            href="#"
            class="p-2 text-indigo-400 transition-colors duration-200 rounded-full bg-indigo-50 hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:bg-indigo-100 dark:focus:bg-indigo-700 focus:ring-indigo-800"
            >
            <span class="sr-only">Users</span>
            <svg
                class="w-7 h-7"
                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="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
                />
            </svg>
            </a>
        </div>
        <!-- Sidebar footer -->
        <!-- prevent default just to prevent form submission in this demo -->
        <form @submit="$event.preventDefault()" action="#" class="flex items-center justify-center flex-shrink-0">
            <!-- Logout button -->
            <button
            class="p-2 text-indigo-400 transition-colors duration-200 rounded-full bg-indigo-50 hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:bg-indigo-100 dark:focus:bg-indigo-700 focus:ring-indigo-800"
            >
            <span class="sr-only">Logout</span>
            <svg
                class="w-7 h-7"
                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="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"
                />
            </svg>
            </button>
        </form>
        </nav>
    </aside>

    <div class="flex flex-1 h-screen overflow-y-scroll">
        <!-- Main content -->
        <main class="flex-1">
        <header class="flex items-center justify-between p-4">
            <div class="flex items-center space-x-4 md:space-x-0">
            <!-- Sidebar button -->
            <button
                @click="isSidebarOpen = true; $nextTick(() => { $refs.sidebar.focus() })"
                class="p-1 text-indigo-400 transition-colors duration-200 rounded-md bg-indigo-50 md:hidden hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:ring"
            >
                <span class="sr-only">Open main manu</span>
                <span aria-hidden="true">
                <svg
                    x-show="!isSidebarOpen"
                    class="w-8 h-8"
                    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="M4 6h16M4 12h16M4 18h16"
                    />
                </svg>
                <svg
                    x-show="isSidebarOpen"
                    class="w-8 h-8"
                    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="M6 18L18 6M6 6l12 12" />
                </svg>
                </span>
            </button>
            <h1 class="text-2xl font-medium">Home</h1>
            </div>
            <div class="space-x-2">
            <!-- Toggle dark theme button -->
            <button aria-hidden="true" class="relative focus:outline-none" x-cloak @click="toggleTheme">
                <div class="w-12 h-6 transition bg-indigo-100 rounded-full outline-none dark:bg-indigo-400"></div>
                <div
                class="absolute top-0 left-0 inline-flex items-center justify-center w-6 h-6 transition-all duration-150 transform scale-110 rounded-full shadow-sm"
                :class="{ 'translate-x-0 -translate-y-px  bg-white text-indigo-700': !isDark, 'translate-x-6 text-indigo-100 bg-indigo-800': isDark }"
                >
                <svg
                    x-show="!isDark"
                    class="w-4 h-4"
                    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="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
                    />
                </svg>
                <svg
                    x-show="isDark"
                    class="w-4 h-4"
                    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="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"
                    />
                </svg>
                </div>
            </button>
            <!-- Search panel button -->
            <button
                @click="openSearchPanel"
                class="p-1 text-indigo-400 transition-colors duration-200 rounded-md bg-indigo-50 hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:ring"
            >
                <span class="sr-only">Open search panel</span>
                <span aria-hidden="true">
                <svg
                    class="w-8 h-8"
                    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="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
                    />
                </svg>
                </span>
            </button>

            <!-- User panel button -->
            <button
                @click="openUserPanel"
                class="p-1 text-indigo-400 transition-colors duration-200 rounded-md bg-indigo-50 xl:hidden hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:ring"
            >
                <span class="sr-only">Open user panel</span>
                <span aria-hidden="true">
                <svg
                    class="w-8 h-8"
                    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="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"
                    />
                </svg>
                </span>
            </button>
            </div>
        </header>
        <section class="flex flex-col items-center justify-center p-4 space-y-4">
            <h3 class="text-2xl font-semibold text-center md:text-3xl">Mini Sidebar</h3>
            <div class="flex p-1 space-x-1 bg-white shadow-md w-80 h-72 dark:bg-darker">
            <div class="w-6 h-full bg-gray-200 dark:bg-dark"></div>
            <div class="flex-1 h-full bg-gray-100 dark:bg-dark"></div>
            <div class="w-16 h-full bg-gray-200 dark:bg-dark"></div>
            </div>
            <div>
            <p class="text-center">See full project</p>
            <a
                href="https://kamona-wd.github.io/kwd-dashboard/"
                target="_blank"
                class="text-base text-blue-600 hover:underline"
            >
                Live
            </a>
            <a
                href="https://github.com/Kamona-WD/kwd-dashboard"
                target="_blank"
                class="ml-4 text-base text-blue-600 hover:underline"
            >
                Github repo
            </a>
            </div>
        </section>
        <div class="grid grid-cols-1 gap-4 p-4 md:grid-cols-2 xl:grid-cols-4 2xl:grid-cols-6">
            <template x-for="i in 100" x-key="i">
            <div class="p-2 text-center bg-white rounded-md shadow dark:bg-darker">Dummy content</div>
            </template>
        </div>
        </main>
        <!-- User panel -->
        <section
        x-show="isUserPanelOpen"
        x-transition:enter="transition duration-300 ease-in-out transform"
        x-transition:enter-start="translate-x-full"
        x-transition:enter-end="translate-x-0"
        x-transition:leave="transition duration-300 ease-in-out transform"
        x-transition:leave-start="translate-x-0"
        x-transition:leave-end="translate-x-full"
        @keydown.escape="window.innerWidth <= 1024 ? isUserPanelOpen = false : ''"
        tabindex="-1"
        x-ref="userPanel"
        class="fixed inset-y-0 top-0 right-0 z-10 flex-shrink-0 bg-white xl:z-0 xl:sticky w-80 dark:bg-darker dark:text-light xl:border-l dark:border-indigo-800 focus:outline-none"
        >
        <h2 class="sr-only">User panel</h2>
        <!-- Close button -->
        <div class="absolute left-0 p-2 transform -translate-x-full xl:hidden">
            <button
            @click="isUserPanelOpen = false"
            class="p-2 rounded-md text-dark dark:text-light focus:outline-none focus:ring"
            >
            <svg
                class="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="M6 18L18 6M6 6l12 12" />
            </svg>
            </button>
        </div>
        <div class="flex flex-col h-screen">
            <!-- Panel header -->
            <div class="flex-shrink-0 p-4">
            <!-- Settings button -->
            <button
                @click="openSettingsPanel"
                class="p-2 text-indigo-400 transition-colors duration-200 rounded-full bg-indigo-50 hover:text-indigo-600 hover:bg-indigo-100 dark:hover:text-light dark:hover:bg-indigo-700 dark:bg-dark focus:outline-none focus:bg-indigo-100 dark:focus:bg-indigo-700 focus:ring-indigo-800"
            >
                <span class="sr-only">Open settings panel</span>
                <svg
                class="w-7 h-7"
                xmlns="http://www.w3.org/2000/svg"
                fill="none"
                viewBox="0 0 24 24"
                stroke="currentColor"
                aria-hidden="true"
                >
                <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.724 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.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
                />
                <path
                    stroke-linecap="round"
                    stroke-linejoin="round"
                    stroke-width="2"
                    d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
                />
                </svg>
            </button>
            </div>
            <!-- Panel content -->
            <div class="flex-1 p-4 space-y-8 overflow-y-hidden hover:overflow-y-auto">
            <!-- content -->
            <div class="flex flex-col items-center space-y-2">
                <!-- User avatar -->
                <img
                class="w-20 h-20 rounded-full dark:opacity-70"
                src="https://avatars.githubusercontent.com/u/57622665?s=460&u=8f581f4c4acd4c18c33a87b3e6476112325e8b38&v=4"
                alt="Ahmed Kamel"
                />
                <h2 class="text-xl font-medium text-gray-600 dark:text-light">Ahmed Kamel</h2>
            </div>
            <div class="space-y-6">
                <div class="flex items-center justify-between">
                <h3 class="text-lg font-normal text-gray-600 dark:text-light">Messages</h3>
                <a href="#" class="text-blue-500 hover:underline">View all</a>
                </div>

                <div class="space-y-4">
                <a href="#" class="flex items-start space-x-2 group">
                    <img
                    class="flex-shrink-0 object-cover w-12 h-12 rounded-full"
                    src="https://scontent-hbe1-1.xx.fbcdn.net/v/t1.0-9/82125466_110587420467089_5876443407655632896_n.jpg?_nc_cat=102&ccb=3&_nc_sid=09cbfe&_nc_ohc=GrzMqB3w0WMAX_PK3hf&_nc_ht=scontent-hbe1-1.xx&oh=a51c1ffff60c83e73c3ef0c9c70afafa&oe=6056CFF5"
                    alt="John Doe"
                    />
                    <div class="overflow-hidden">
                    <h4
                        class="font-semibold text-gray-400 transition-colors dark:text-indigo-700 group-hover:text-gray-900 dark:group-hover:text-indigo-400"
                    >
                        John Doe
                    </h4>
                    <p class="text-sm text-gray-400 truncate">
                        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quis voluptas eaque nesciunt
                        doloremque ullam
                    </p>
                    </div>
                    <span class="text-xs text-gray-500 whitespace-nowrap dark:text-indigo-500">1h ago</span>
                </a>
                <a href="#" class="flex items-start space-x-2 group">
                    <img
                    class="flex-shrink-0 object-cover w-12 h-12 rounded-full"
                    src="https://pbs.twimg.com/profile_banners/1320412502195306496/1603647296/1500x500"
                    alt="John Doe"
                    />
                    <div class="overflow-hidden">
                    <h4
                        class="font-semibold text-gray-400 transition-colors dark:text-indigo-700 group-hover:text-gray-900 dark:group-hover:text-indigo-400"
                    >
                        Someone
                    </h4>
                    <p class="text-sm text-gray-400 truncate">
                        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quis voluptas eaque nesciunt
                        doloremque ullam
                    </p>
                    </div>
                    <span class="text-xs text-gray-500 whitespace-nowrap dark:text-indigo-500">1h ago</span>
                </a>
                </div>
            </div>
            </div>
            <!-- Panel footer -->
            <footer class="flex items-center justify-between flex-shrink-0 px-4 py-2 border-t dark:border-indigo-800">
            <div class="text-sm">
                View on
                <a
                href="https://github.com/Kamona-WD/kwd-dashboard"
                target="_blank"
                class="text-blue-500 hover:underline"
                >
                github
                </a>
            </div>
            <div class="text-sm">
                Made by
                <a href="https://github.com/Kamona-WD" target="_blank" class="text-blue-500 hover:underline">
                Ahmed Kamel
                </a>
            </div>
            </footer>
        </div>
        </section>
    </div>

    <!-- Panels -->

    <!-- Settings Panel -->
    <!-- Backdrop -->
    <div
        x-transition:enter="transition duration-300 ease-in-out"
        x-transition:enter-start="opacity-0"
        x-transition:enter-end="opacity-100"
        x-transition:leave="transition duration-300 ease-in-out"
        x-transition:leave-start="opacity-100"
        x-transition:leave-end="opacity-0"
        x-show="isSettingsPanelOpen"
        @click="isSettingsPanelOpen = false"
        class="fixed inset-0 z-10 bg-indigo-800"
        style="opacity: 0.5"
        aria-hidden="true"
    ></div>
    <!-- Panel -->
    <section
        x-transition:enter="transition duration-300 ease-in-out transform sm:duration-500"
        x-transition:enter-start="translate-x-full"
        x-transition:enter-end="translate-x-0"
        x-transition:leave="transition duration-300 ease-in-out transform sm:duration-500"
        x-transition:leave-start="translate-x-0"
        x-transition:leave-end="translate-x-full"
        x-ref="settingsPanel"
        tabindex="-1"
        x-show="isSettingsPanelOpen"
        @keydown.escape="isSettingsPanelOpen = false"
        class="fixed inset-y-0 right-0 z-20 w-full max-w-xs bg-white shadow-xl dark:bg-darker dark:text-light sm:max-w-md focus:outline-none"
        aria-labelledby="settinsPanelLabel"
    >
        <div class="absolute left-0 p-2 transform -translate-x-full">
        <!-- Close button -->
        <button
            @click="isSettingsPanelOpen = false"
            class="p-2 text-white rounded-md focus:outline-none focus:ring"
        >
            <svg
            class="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="M6 18L18 6M6 6l12 12" />
            </svg>
        </button>
        </div>
        <!-- Panel content -->
        <div class="flex flex-col h-screen">
        <!-- Panel header -->
        <div
            class="flex flex-col items-center justify-center flex-shrink-0 px-4 py-8 space-y-4 border-b dark:border-indigo-700"
        >
            <span aria-hidden="true" class="text-gray-500 dark:text-indigo-600">
            <svg
                class="w-8 h-8"
                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="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"
                />
            </svg>
            </span>
            <h2 id="settinsPanelLabel" class="text-xl font-medium text-gray-500 dark:text-light">Settings</h2>
        </div>
        <!-- Content -->
        <div class="flex-1 overflow-hidden hover:overflow-y-auto">
            <!-- Theme -->
            <div class="p-4 space-y-4 md:p-8">
            <h6 class="text-lg font-medium text-gray-400 dark:text-light">Mode</h6>
            <div class="flex items-center space-x-8">
                <!-- Light button -->
                <button
                @click="setLightTheme"
                class="flex items-center justify-center px-4 py-2 space-x-4 transition-colors border rounded-md hover:text-gray-900 hover:border-gray-900 dark:border-indigo-600 dark:hover:text-indigo-100 dark:hover:border-indigo-500 focus:outline-none focus:ring focus:ring-indigo-400 dark:focus:ring-indigo-700"
                :class="{ 'border-gray-900 text-gray-900 dark:border-indigo-500 dark:text-indigo-100': !isDark, 'text-gray-500 dark:text-indigo-500': isDark }"
                >
                <span>
                    <svg
                    class="w-6 h-6"
                    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="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"
                    />
                    </svg>
                </span>
                <span>Light</span>
                </button>

                <!-- Dark button -->
                <button
                @click="setDarkTheme"
                class="flex items-center justify-center px-4 py-2 space-x-4 transition-colors border rounded-md hover:text-gray-900 hover:border-gray-900 dark:border-indigo-600 dark:hover:text-indigo-100 dark:hover:border-indigo-500 focus:outline-none focus:ring focus:ring-indigo-400 dark:focus:ring-indigo-700"
                :class="{ 'border-gray-900 text-gray-900 dark:border-indigo-500 dark:text-indigo-100': isDark, 'text-gray-500 dark:text-indigo-500': !isDark }"
                >
                <span>
                    <svg
                    class="w-6 h-6"
                    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="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
                    />
                    </svg>
                </span>
                <span>Dark</span>
                </button>
            </div>
            </div>

            <!--  -->
            <div class="p-4 space-y-4 md:p-8">
            <!--  -->
            </div>
        </div>
        </div>
    </section>

    <!-- Search panel -->
    <!-- Backdrop -->
    <div
        x-transition:enter="transition duration-300 ease-in-out"
        x-transition:enter-start="opacity-0"
        x-transition:enter-end="opacity-100"
        x-transition:leave="transition duration-300 ease-in-out"
        x-transition:leave-start="opacity-100"
        x-transition:leave-end="opacity-0"
        x-show="isSearchPanelOpen"
        @click="isSearchPanelOpen = false"
        class="fixed inset-0 z-10 bg-indigo-800"
        style="opacity: 0.5"
        aria-hidden="ture"
    ></div>
    <!-- Panel -->
    <section
        x-transition:enter="transition duration-300 ease-in-out transform sm:duration-500"
        x-transition:enter-start="-translate-x-full"
        x-transition:enter-end="translate-x-0"
        x-transition:leave="transition duration-300 ease-in-out transform sm:duration-500"
        x-transition:leave-start="translate-x-0"
        x-transition:leave-end="-translate-x-full"
        x-show="isSearchPanelOpen"
        @keydown.escape="isSearchPanelOpen = false"
        class="fixed inset-y-0 z-20 w-full max-w-xs bg-white shadow-xl dark:bg-darker dark:text-light sm:max-w-md focus:outline-none"
    >
        <div class="absolute right-0 p-2 transform translate-x-full">
        <!-- Close button -->
        <button @click="isSearchPanelOpen = false" class="p-2 text-white rounded-md focus:outline-none focus:ring">
            <svg
            class="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="M6 18L18 6M6 6l12 12" />
            </svg>
        </button>
        </div>

        <h2 class="sr-only">Search panel</h2>
        <!-- Panel content -->
        <div class="flex flex-col h-screen">
        <!-- Panel header (Search input) -->
        <div
            class="relative flex-shrink-0 px-4 py-8 text-gray-400 border-b dark:border-indigo-800 dark:focus-within:text-light focus-within:text-gray-700"
        >
            <span class="absolute inset-y-0 inline-flex items-center px-4">
            <svg
                class="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="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
                />
            </svg>
            </span>
            <input
            x-ref="searchInput"
            type="text"
            class="w-full py-2 pl-10 pr-4 border rounded-full dark:bg-dark dark:border-transparent dark:text-light focus:outline-none focus:ring"
            placeholder="Search..."
            />
        </div>

        <!-- Panel content (Search result) -->
        <div class="flex-1 px-4 pb-4 space-y-4 overflow-y-hidden h hover:overflow-y-auto">
            <h3 class="py-2 text-sm font-semibold text-gray-600 dark:text-light">History</h3>
            <p class="px=4">Search resault</p>
            <!--  -->
            <!-- Search content -->
            <!--  -->
        </div>
        </div>
    </section>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/gh/alpine-collective/[email protected]/dist/component.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>

<script>
    const setup = () => {
    const getTheme = () => {
        if (window.localStorage.getItem('dark')) {
        return JSON.parse(window.localStorage.getItem('dark'))
        }
        return !!window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
    }

    const setTheme = (value) => {
        window.localStorage.setItem('dark', value)
    }

    return {
        loading: true,
        isDark: getTheme(),
        toggleTheme() {
            this.isDark = !this.isDark
            setTheme(this.isDark)
        },
        setLightTheme() {
            this.isDark = false
            setTheme(this.isDark)
        },
        setDarkTheme() {
            this.isDark = true
            setTheme(this.isDark)
        },
        watchScreen() {
            if (window.innerWidth <= 768) {
                this.isSidebarOpen = false
                this.isUserPanelOpen = false
            } else if (window.innerWidth >= 768 && window.innerWidth < 1280) {
                this.isSidebarOpen = true
                this.isUserPanelOpen = false
            } else if (window.innerWidth >= 1280) {
                this.isSidebarOpen = true
                this.isUserPanelOpen = true
            }
        },
        isSidebarOpen: window.innerWidth >= 768 ? true : false,
        toggleSidbarMenu() {
            this.isSidebarOpen = !this.isSidebarOpen
        },
        isUserPanelOpen: window.innerWidth >= 1280 ? true : false,
        openUserPanel() {
            this.isUserPanelOpen = true
            this.$nextTick(() => {
                this.$refs.userPanel.focus()
            })
        },
        isSettingsPanelOpen: false,
        openSettingsPanel() {
            this.isSettingsPanelOpen = true
            this.$nextTick(() => {
                this.$refs.settingsPanel.focus()
            })
        },
        isNotificationsPanelOpen: false,
        openNotificationsPanel() {
            this.isNotificationsPanelOpen = true
            this.$nextTick(() => {
                this.$refs.notificationsPanel.focus()
            })
        },
        isSearchPanelOpen: false,
        openSearchPanel() {
            this.isSearchPanelOpen = true
            this.$nextTick(() => {
                this.$refs.searchInput.focus()
            })
        },
    }
}
</script>

How to make a Mini column sidebar with Tailwind CSS?

Install tailwind css of verion 2.0.2

Use the script html tag to import the script of Tailwind CSS of the version 2.0.2

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to make a Mini column sidebar component

  • flex
  • h-screen
  • text-gray-900
  • bg-gray-100
  • dark:bg-dark
  • dark:text-light
  • fixed
  • z-50
  • text-2xl
  • text-white
  • bg-indigo-800
  • z-10
  • md:hidden
  • flex-shrink-0
  • bg-white
  • border-r
  • md:static
  • dark:border-indigo-800
  • dark:bg-darker
  • flex-col
  • h-full
  • px-2
  • py-4
  • inline-block
  • text-xl
  • text-indigo-700
  • flex-1
  • p-2
  • bg-indigo-600
  • hover:text-indigo-600
  • hover:bg-indigo-100
  • focus:bg-indigo-100
  • w-7
  • h-7
  • text-indigo-400
  • bg-indigo-50
  • overflow-y-scroll
  • p-4
  • p-1
  • w-8
  • h-8
  • relative
  • w-12
  • h-6
  • bg-indigo-100
  • dark:bg-indigo-400
  • absolute
  • top-0
  • left-0
  • inline-flex
  • w-6
  • text-indigo-100
  • w-4
  • h-4
  • xl:hidden
  • text-center
  • md:text-3xl
  • w-80
  • h-72
  • bg-gray-200
  • w-16
  • text-base
  • text-blue-600
  • ml-4
  • grid
  • grid-cols-1
  • gap-4
  • md:grid-cols-2
  • xl:grid-cols-4
  • 2xl:grid-cols-6
  • right-0
  • xl:z-0
  • xl:sticky
  • xl:border-l
  • text-dark
  • w-5
  • h-5
  • hover:overflow-y-auto
  • w-20
  • h-20
  • text-gray-600
  • text-lg
  • text-blue-500
  • h-12
  • overflow-hidden
  • text-gray-400
  • dark:text-indigo-700
  • group-hover:text-gray-900
  • text-sm
  • text-xs
  • text-gray-500
  • dark:text-indigo-500
  • px-4
  • py-2
  • border-t
  • z-20
  • w-full
  • max-w-xs
  • sm:max-w-md
  • py-8
  • border-b
  • dark:border-indigo-700
  • dark:text-indigo-600
  • md:p-8
  • hover:text-gray-900
  • hover:border-gray-900
  • dark:border-indigo-600
  • border-gray-900
  • dark:border-indigo-500
  • dark:text-indigo-100
  • focus-within:text-gray-700
  • pl-10
  • pr-4
  • dark:border-transparent
  • pb-4

115 steps to make a Mini column sidebar component with Tailwind CSS

  1. Use flex to create a block-level flex container.

  2. Use h-screen to make an element span the entire height of the viewport.

  3. Control the text color of an element to gray-900 using the text-gray-900 utilities.

  4. Control the background color of an element to gray-100 using the bg-gray-100 utilities.

  5. Control the background color of an element to dark using the dark:bg-dark utilities in dark theme.

  6. Control the text color of an element to light in dark theme using the dark:text-light utilities.

  7. Use fixed to position an element relative to the browser window.

  8. Control the stack order (or three-dimensional positioning) of an element to 50 in Tailwind, regardless of order it has been displayed, using the z-50 utilities.

  9. Control the text color of an element to 2xl using the text-2xl utilities.

  10. Control the text color of an element to white using the text-white utilities.

  11. Control the background color of an element to indigo-800 using the bg-indigo-800 utilities.

  12. Control the stack order (or three-dimensional positioning) of an element to 10 in Tailwind, regardless of order it has been displayed, using the z-10 utilities.

  13. Use hidden to set an element to display: none and remove it from the page layout at only medium screen sizes.

  14. Use flex to create a block-level flex container.

  15. Control the background color of an element to white using the bg-white utilities.

  16. Control the border color of an element to r using the border-r utilities.

  17. Use static to position an element according to the normal flow of the document at only medium screen sizes.

  18. Control the border color of an element to indigo-800 using the dark:border-indigo-800 utilities in dark theme.

  19. Control the background color of an element to darker using the dark:bg-darker utilities in dark theme.

  20. Use flex to create a block-level flex container.

  21. Use h-full to set an element’s height to 100% of its parent, as long as the parent has a defined height.

  22. Control the horizontal padding of an element to 0.5rem using the px-2 utilities.

  23. Control the vertical padding of an element to 1rem using the py-4 utilities.

  24. Use inline-block utilities to wrap the element to prevent the text inside from extending beyond its parent.

  25. Control the text color of an element to xl using the text-xl utilities.

  26. Control the text color of an element to indigo-700 using the text-indigo-700 utilities.

  27. Use flex to create a block-level flex container.

  28. Control the padding on all sides of an element to 0.5rem using the p-2 utilities.

  29. Control the background color of an element to indigo-600 using the bg-indigo-600 utilities.

  30. Control the text color of an element to indigo-600 on hover using the hover:text-indigo-600 utilities.

  31. Control the background color of an element to indigo-100 using the hover:bg-indigo-100 utilities on hover.

  32. Control the background color of an element to indigo-100 using the focus:bg-indigo-100 utilities on focus.

  33. Use w-7 to set an element to a fixed width(1.75rem).

  34. Use h-7 to set an element to a fixed height(1.75rem).

  35. Control the text color of an element to indigo-400 using the text-indigo-400 utilities.

  36. Control the background color of an element to indigo-50 using the bg-indigo-50 utilities.

  37. Use overflow-y-scroll to allow vertical scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.

  38. Control the padding on all sides of an element to 1rem using the p-4 utilities.

  39. Control the padding on all sides of an element to 0.25rem using the p-1 utilities.

  40. Use w-8 to set an element to a fixed width(2rem).

  41. Use h-8 to set an element to a fixed height(2rem).

  42. Use relative to position an element according to the normal flow of the document.

  43. Use w-12 to set an element to a fixed width(3rem).

  44. Use h-6 to set an element to a fixed height(1.5rem).

  45. Control the background color of an element to indigo-100 using the bg-indigo-100 utilities.

  46. Control the background color of an element to indigo-400 using the dark:bg-indigo-400 utilities in dark theme.

  47. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

  48. Use the top-0 utilities to set the top position of a positioned element to 0rem.

  49. Use the left-0 utilities to set the left position of a positioned element to 0rem.

  50. Use inline-flex to create an inline flex container that flows with text.

  51. Use w-6 to set an element to a fixed width(1.5rem).

  52. Control the text color of an element to indigo-100 using the text-indigo-100 utilities.

  53. Use w-4 to set an element to a fixed width(1rem).

  54. Use h-4 to set an element to a fixed height(1rem).

  55. Use hidden to set an element to display: none and remove it from the page layout at only extremely large screen sizes.

  56. Control the text color of an element to center using the text-center utilities.

  57. Control the text color of an element to 3xl at only medium screen sizes using the md:text-3xl utilities.

  58. Use w-80 to set an element to a fixed width(20rem).

  59. Use h-72 to set an element to a fixed height(18rem).

  60. Control the background color of an element to gray-200 using the bg-gray-200 utilities.

  61. Use w-16 to set an element to a fixed width(4rem).

  62. Control the text color of an element to base using the text-base utilities.

  63. Control the text color of an element to blue-600 using the text-blue-600 utilities.

  64. Control the margin on left side of an element to 1rem using the ml-4 utilities.

  65. Use grid to create a grid container.

  66. Use grid to create a grid container.

  67. To specify the width between columns, you can use the gap-4 utilities.

  68. Use grid to create a grid container at only medium screen sizes.

  69. Use grid to create a grid container at only extremely large screen sizes.

  70. Use grid to create a grid containerundefined.

  71. Use the right-0 utilities to set the right position of a positioned element to 0rem.

  72. Control the stack order (or three-dimensional positioning) of an element to 0 at only extremely large screen sizes in Tailwind, regardless of order it has been displayed, using the xl:z-0 utilities.

  73. Use sticky to position an element as relative until it crosses a specified threshold at only extremely large screen sizes, then treat it as fixed until its parent is off screen.

  74. Control the border color of an element to l using the xl:border-l utilities at only extremely large screen sizes.

  75. Control the text color of an element to dark using the text-dark utilities.

  76. Use w-5 to set an element to a fixed width(1.25rem).

  77. Use h-5 to set an element to a fixed height(1.25rem).

  78. Use overflow-y-auto to allow vertical scrolling if needed on hover.

  79. Use w-20 to set an element to a fixed width(5rem).

  80. Use h-20 to set an element to a fixed height(5rem).

  81. Control the text color of an element to gray-600 using the text-gray-600 utilities.

  82. Control the text color of an element to lg using the text-lg utilities.

  83. Control the text color of an element to blue-500 using the text-blue-500 utilities.

  84. Use h-12 to set an element to a fixed height(3rem).

  85. Use overflow-hidden to clip any content within an element that overflows the bounds of that element.

  86. Control the text color of an element to gray-400 using the text-gray-400 utilities.

  87. Control the text color of an element to indigo-700 in dark theme using the dark:text-indigo-700 utilities.

  88. Control the text color of an element to gray-900undefined using the group-hover:text-gray-900 utilities.

  89. Control the text color of an element to sm using the text-sm utilities.

  90. Control the text color of an element to xs using the text-xs utilities.

  91. Control the text color of an element to gray-500 using the text-gray-500 utilities.

  92. Control the text color of an element to indigo-500 in dark theme using the dark:text-indigo-500 utilities.

  93. Control the horizontal padding of an element to 1rem using the px-4 utilities.

  94. Control the vertical padding of an element to 0.5rem using the py-2 utilities.

  95. Control the border color of an element to t using the border-t utilities.

  96. Control the stack order (or three-dimensional positioning) of an element to 20 in Tailwind, regardless of order it has been displayed, using the z-20 utilities.

  97. Use w-full to set an element to a 100% based width.

  98. Set the maximum width/height of an element using the max-w-xs utilities.

  99. Set the maximum width/height of an element using the sm:max-w-md utilities at only small screen sizes.

  100. Control the vertical padding of an element to 2rem using the py-8 utilities.

  101. Control the border color of an element to b using the border-b utilities.

  102. Control the border color of an element to indigo-700 using the dark:border-indigo-700 utilities in dark theme.

  103. Control the text color of an element to indigo-600 in dark theme using the dark:text-indigo-600 utilities.

  104. Control the padding on all sides of an element to 2rem at only medium screen sizes using the md:p-8 utilities.

  105. Control the text color of an element to gray-900 on hover using the hover:text-gray-900 utilities.

  106. Control the border color of an element to gray-900 using the hover:border-gray-900 utilities on hover.

  107. Control the border color of an element to indigo-600 using the dark:border-indigo-600 utilities in dark theme.

  108. Control the border color of an element to gray-900 using the border-gray-900 utilities.

  109. Control the border color of an element to indigo-500 using the dark:border-indigo-500 utilities in dark theme.

  110. Control the text color of an element to indigo-100 in dark theme using the dark:text-indigo-100 utilities.

  111. Control the text color of an element to gray-700undefined using the focus-within:text-gray-700 utilities.

  112. Set the left padding of an element to 2.5rem using the pl-10 utilities class

  113. Control the padding on right side of an element to 1rem using the pr-4 utilities.

  114. Control the border color of an element to transparent using the dark:border-transparent utilities in dark theme.

  115. Control the padding on bottom side of an element to 1rem using the pb-4 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to make a Mini column sidebar components, learn and follow along to implement your own components.