- Published on
Surprisingly Effective Ways To Build A Simple Dashboard Layout With Tailwind CSS

- What is Tailwind CSS?
- The description of Simple Dashboard Layout ui component
- Why use Tailwind CSS to build a Simple Dashboard Layout ui component?
- The preview of Simple Dashboard Layout ui component
- The source code of Simple Dashboard Layout ui component
- How to build a Simple Dashboard Layout with Tailwind CSS?
- Install tailwind css of verion 2.0.1
- All the unility class needed to build a Simple Dashboard Layout component
- 119 steps to build a Simple Dashboard Layout component with Tailwind CSS
- Conclusion
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 Simple Dashboard Layout ui component
Simple responsive dashboard layout
Why use Tailwind CSS to build a Simple Dashboard Layout ui component?
- It can make the building process of Simple Dashboard Layout ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Simple Dashboard Layout component file.
The preview of Simple Dashboard Layout ui component
Free download of the Simple Dashboard Layout's source code
The source code of Simple Dashboard Layout ui component
<!-- This is an example component -->
<div>
<div
class="relative flex h-screen bg-blue-50"
x-data="setup()"
x-init="$refs.loadingScreen.classList.add('hidden')"
>
<!-- Loading Screen -->
<div
x-ref="loadingScreen"
class="fixed inset-0 z-50 flex items-center justify-center bg-blue-600 bg-opacity-20"
style="backdrop-filter: blur(14px)"
>
<span class="text-2xl">Loading...</span>
</div>
<!-- Sidebar -->
<aside
class="fixed left-0 right-0 z-10 flex-col flex-shrink-0 h-full overflow-hidden transition-all bg-transparent bottom-10 xl:h-screen top-16 xl:static xl:z-auto"
:class="{'flex xl:w-64': isSidebarOpen, 'hidden xl:flex xl:w-16': !isSidebarOpen}"
>
<!-- Sidebar header -->
<div
class="flex-shrink-0 hidden px-2 max-h-14 xl:items-center xl:justify-start xl:space-x-3 xl:flex xl:max-h-14 xl:h-full xl:px-4"
>
<!-- Sidebar Button -->
<button @click="toggleSidebar" class="p-2 text-blue-600 rounded-full hover:bg-blue-200">
<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="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
<!-- Logo -->
<a
href="#"
:class="{'xl:hidden': !isSidebarOpen}"
class="flex-shrink-0 text-2xl font-bold tracking-widest text-blue-800 uppercase"
>
K-WD
</a>
</div>
<!-- Sidebar Content -->
<div
class="fixed left-0 flex flex-col flex-1 max-h-screen px-2 overflow-hidden right-3 top-16 bottom-10 xl:static xl:pt-2 xl:pl-4 xl:mb-4"
>
<div
:class="{'min-w-full xl:w-14': isSidebarOpen}"
class="flex-1 max-h-full p-2 overflow-y-auto bg-white rounded-md shadow-2xl lg:shadow-md"
>
<nav class="">
<ul class="space-y-2">
<!-- <template x-for="i in 30" :key="i"> -->
<li class="">
<button class="flex items-center space-x-2">
<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="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>
</span>
<span :class="{'xl:hidden': !isSidebarOpen}"> Dashboard </span>
</button>
</li>
<!-- </template> -->
</ul>
</nav>
</div>
</div>
</aside>
<div class="relative flex flex-col flex-1 h-full max-h-full overflow-y-scroll">
<!-- Navbar -->
<header class="sticky top-0 flex items-center flex-shrink-0 w-full h-full bg-opacity-100 bg-blue-50 max-h-14">
<!-- Menu Button -->
<div class="flex items-center flex-shrink-0 xl:hidden">
<button @click="toggleSidebar" class="p-2 text-blue-600 rounded-full hover:bg-blue-200">
<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="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
</div>
<div class="flex items-center justify-between flex-1">
<!-- Logo -->
<a
href="#"
:class="{'xl:hidden ml-2':isSidebarOpen, 'block ml-2':!isSidebarOpen}"
class="flex-shrink-0 text-2xl font-bold tracking-widest text-blue-800 uppercase"
>
K-WD
</a>
<nav class="relative flex items-center justify-end flex-1 ml-3 lg:justify-start">
<!-- Search Button -->
<div x-data="{ searchOpen: false, searchResult: false }">
<button
@click="searchOpen = !searchOpen"
class="inline-block p-2 bg-blue-100 rounded-full hover:bg-blue-200"
>
<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="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
/>
</svg>
</button>
<!-- Search box -->
<div
@click.away="searchOpen = false"
x-show.transition="searchOpen"
class="fixed left-0 ml-2 right-6 lg:max-w-md lg:-ml-1 lg:absolute"
>
<div class="p-4 mt-4 bg-white shadow-lg rounded-t-md">
<div class="flex items-center">
<input
type="text"
placeholder="Search..."
class="w-full px-4 py-2 bg-blue-100 rounded-l-md focus:outline-none"
@focus="searchResult = true"
@blur="searchResult = false"
/>
<button
class="p-2 text-white bg-blue-500 rounded-r-md focus:outline-none hover:bg-blue-600 focus:bg-blue-700"
>
<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="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
/>
</svg>
</button>
</div>
</div>
<!-- Search Result -->
<div
x-show.transition="searchResult"
class="p-4 overflow-y-auto bg-white shadow-lg rounded-b-md h-72"
>
<ul>
<template x-for="i in 10" :key="i">
<li>
<a href="#" class="block px-4 py-2 rounded-md hover:bg-blue-100">Result</a>
</li>
</template>
</ul>
</div>
</div>
</div>
<!-- Left Links -->
<ul class="items-center justify-center hidden ml-3 space-x-2 lg:flex">
<!-- Services Menu -->
<li x-data="{ open: false }">
<button
@click="open = !open"
class="inline-flex items-center px-4 py-2 space-x-2 rounded-md hover:bg-blue-100"
>
<span>Services</span>
<span>
<svg
class="w-3 h-3 text-gray-600"
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="M19 9l-7 7-7-7" />
</svg>
</span>
</button>
<div
x-show.transition="open"
@click.away="open = false"
class="absolute w-full max-w-lg p-2 mt-4 bg-white rounded-md shadow-md"
>
<div class="px-2 my-2">Ugly placeholder</div>
<div class="grid grid-cols-3 gap-6">
<template x-for="i in 3">
<ul class="">
<template x-for="x in 5">
<li>
<a
href="#"
class="flex items-center justify-between px-4 py-1 rounded-md hover:bg-blue-100"
>
<span>Placeholder</span>
<span class="p-1 bg-blue-200 rounded-md">20</span>
</a>
</li>
</template>
</ul>
</template>
</div>
</div>
</li>
<!-- Apps Menu -->
<li>
<button class="inline-flex items-center px-4 py-2 space-x-2 rounded-md hover:bg-blue-100">
<span>Apps</span>
<span>
<svg
class="w-3 h-3 text-gray-600"
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="M19 9l-7 7-7-7" />
</svg>
</span>
</button>
</li>
</ul>
<!-- Right Links -->
<ul class="flex items-center justify-center ml-auto mr-2 space-x-2 lg:mr-5">
<!-- Github Link -->
<li class="relative">
<div class="absolute inset-0 flex items-center justify-center" style="z-index: -1">
<span class="block w-5 h-5 bg-red-600 rounded-full animate-ping"></span>
</div>
<a
href="https://github.com/Kamona-WD/simple-dashboard"
target="_blank"
class="inline-flex p-2 bg-blue-200 rounded-full bg-opacity-20 hover:bg-blue-300 hover:bg-opacity-20"
style="backdrop-filter: blur(14px)"
>
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path
d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"
/>
</svg>
</a>
</li>
<!-- Settings Button -->
<li>
<button
@click="toggleSettingsPanel"
class="inline-block p-2 bg-blue-100 rounded-full hover:bg-blue-200"
>
<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="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>
</li>
<!-- Notifications Button -->
<li>
<button class="inline-block p-2 bg-blue-100 rounded-full hover:bg-blue-200">
<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="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
/>
</svg>
</button>
</li>
<!-- Avatar Button -->
<li>
<button class="p-px border-2 border-blue-100 rounded-full w-11 h-11">
<img
class="block object-cover rounded-full"
src="https://avatars0.githubusercontent.com/u/57622665?s=460&u=8f581f4c4acd4c18c33a87b3e6476112325e8b38&v=4"
alt="Ahmed Kamel"
/>
</button>
</li>
</ul>
</nav>
</div>
</header>
<div class="flex flex-col flex-1 max-h-full pl-2 pr-2 rounded-md xl:pr-4">
<!-- Main Content -->
<main class="flex-1 pt-2">
<!-- Placeholder Cards -->
<div class="p-4 text-white bg-blue-500 rounded-md shadow-md">
<div class="flex items-center justify-center">
<span class="text-3xl font-semibold tracking-wider uppercase">In Progress</span>
</div>
</div>
<div class="flex items-center justify-center p-4 mt-4 bg-white rounded-md shadow-md">
<span class="text-xl tracking-wider text-gray-500 uppercase">placeholder</span>
</div>
<div class="grid grid-cols-1 gap-6 mt-4 md:grid-cols-2">
<template x-for="i in 4" :key="i">
<div class="flex items-center justify-center w-full h-32 bg-white rounded-md shadow-md">
<span class="text-xl tracking-wider text-gray-500 uppercase">placeholder</span>
</div>
</template>
</div>
<div class="grid grid-cols-1 gap-6 my-4 mt-4">
<template x-for="i in 4" :key="i">
<div class="flex items-center justify-center w-full h-56 bg-white rounded-md shadow-md">
<span class="text-xl tracking-wider text-gray-500 uppercase">placeholder</span>
</div>
</template>
</div>
</main>
<!-- Main Footer -->
<footer class="flex-shrink-0">
<div class="py-2 mb-2">
Made by
<a class="text-blue-600 underline" href="https://github.com/Kamona-WD" target="_blank">Ahmed Kamel</a>
</div>
</footer>
</div>
</div>
<!-- Settings Panel -->
<div
@click="isSettingsPanelOpen = false"
x-show.transition.opacity.100="isSettingsPanelOpen"
class="fixed inset-0 z-20 bg-blue-400 bg-opacity-20"
style="backdrop-filter: blur(10px)"
></div>
<div
x-show="isSettingsPanelOpen"
x-transition:enter="transform duration-100"
x-transition:enter-start="translate-x-full ease"
x-transition:enter-end="translate-x-0 ease-in"
x-transition:leave="transform duration-200"
x-transition:leave-start="translate-x-0 ease-out"
x-transition:leave-end="translate-x-full ease"
class="fixed inset-y-0 right-0 z-30 w-full max-w-sm p-2 bg-white"
>
<button @click="toggleSettingsPanel" class="p-4 rounded-md">
<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="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
<script>
function setup() {
return {
isSidebarOpen: false,
toggleSidebar() {
this.isSidebarOpen = !this.isSidebarOpen
},
isSettingsPanelOpen: false,
toggleSettingsPanel() {
this.isSettingsPanelOpen = !this.isSettingsPanelOpen
},
}
}
</script>
</div>
How to build a Simple Dashboard Layout with Tailwind CSS?
Install tailwind css of verion 2.0.1
Use the script
html tag to import the script of Tailwind CSS of the version 2.0.1
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to build a Simple Dashboard Layout component
relative
flex
h-screen
bg-blue-50
fixed
z-50
bg-blue-600
bg-opacity-20
text-2xl
left-0
right-0
z-10
flex-col
flex-shrink-0
h-full
overflow-hidden
bg-transparent
bottom-10
xl:h-screen
top-16
xl:static
xl:z-auto
xl:w-64
hidden
xl:flex
xl:w-16
px-2
max-h-14
xl:justify-start
xl:max-h-14
xl:h-full
xl:px-4
p-2
text-blue-600
hover:bg-blue-200
w-6
h-6
xl:hidden
text-blue-800
flex-1
max-h-screen
right-3
xl:pt-2
xl:pl-4
xl:mb-4
min-w-full
xl:w-14
max-h-full
overflow-y-auto
bg-white
overflow-y-scroll
sticky
top-0
w-full
bg-opacity-100
block
ml-3
lg:justify-start
inline-block
bg-blue-100
ml-2
right-6
lg:max-w-md
lg:-ml-1
lg:absolute
p-4
mt-4
px-4
py-2
text-white
bg-blue-500
hover:bg-blue-600
focus:bg-blue-700
h-72
hover:bg-blue-100
lg:flex
inline-flex
w-3
h-3
text-gray-600
absolute
max-w-lg
my-2
grid
grid-cols-3
gap-6
py-1
p-1
bg-blue-200
ml-auto
mr-2
lg:mr-5
w-5
h-5
bg-red-600
hover:bg-blue-300
hover:bg-opacity-20
p-px
border-2
border-blue-100
w-11
h-11
pl-2
pr-2
xl:pr-4
pt-2
text-3xl
text-xl
text-gray-500
grid-cols-1
md:grid-cols-2
h-32
my-4
h-56
mb-2
z-20
bg-blue-400
z-30
max-w-sm
119 steps to build a Simple Dashboard Layout component with Tailwind CSS
Use
relative
to position an element according to the normal flow of the document.Use
flex
to create a block-level flex container.Use
h-screen
to make an element span the entire height of the viewport.Control the background color of an element to blue-50 using the
bg-blue-50
utilities.Use
fixed
to position an element relative to the browser window.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.Control the background color of an element to blue-600 using the
bg-blue-600
utilities.Control the background color of an element to opacity-20 using the
bg-opacity-20
utilities.Control the text color of an element to 2xl using the
text-2xl
utilities.Use the
left-0
utilities to set the left position of a positioned element to 0rem.Use the
right-0
utilities to set the right position of a positioned element to 0rem.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.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container.Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Control the background color of an element to transparent using the
bg-transparent
utilities.Use the
bottom-10
utilities to set the bottom position of a positioned element to 2.5rem.Use
h-screen
to make an element span the entire height of the viewport at only extremely large screen sizes.Use the
top-16
utilities to set the top position of a positioned element to 4rem.Use
static
to position an element according to the normal flow of the document at only extremely large screen sizes.Control the stack order (or three-dimensional positioning) of an element to auto at only extremely large screen sizes in Tailwind, regardless of order it has been displayed, using the
xl:z-auto
utilities.Use
xl:w-64
to set an element to a fixed width(16rem) at only extremely large screen sizes.Use
hidden
to set an element to display: none and remove it from the page layout.Use
flex
to create a block-level flex container at only extremely large screen sizes.Use
xl:w-16
to set an element to a fixed width(4rem) at only extremely large screen sizes.Control the horizontal padding of an element to 0.5rem using the
px-2
utilities.Set the maximum width/height of an element using the
max-h-14
utilities.Use
justify-start
to justify items against the start of the container’s main axis at only extremely large screen sizes.Set the maximum width/height of an element using the
xl:max-h-14
utilities at only extremely large screen sizes.Use
h-full
to set an element’s height to 100% of its parent at only extremely large screen sizes, as long as the parent has a defined height.Control the horizontal padding of an element to 1rem at only extremely large screen sizes using the
xl:px-4
utilities.Control the padding on all sides of an element to 0.5rem using the
p-2
utilities.Control the text color of an element to blue-600 using the
text-blue-600
utilities.Control the background color of an element to blue-200 using the
hover:bg-blue-200
utilities on hover.Use
w-6
to set an element to a fixed width(1.5rem).Use
h-6
to set an element to a fixed height(1.5rem).Use
hidden
to set an element to display: none and remove it from the page layout at only extremely large screen sizes.Control the text color of an element to blue-800 using the
text-blue-800
utilities.Use
flex
to create a block-level flex container.Set the maximum width/height of an element using the
max-h-screen
utilities.Use the
right-3
utilities to set the right position of a positioned element to 0.75rem.Control the padding on top side of an element to 0.5rem at only extremely large screen sizes using the
xl:pt-2
utilities.Set the left padding of the element to 1rem at only extremely large screen sizes using the
xl:pl-4
utilities classControl the margin on bottom side of an element to 1rem at only extremely large screen sizes using the
xl:mb-4
utilities.Set the minimum width/height of an element using the
min-w-full
utilities.Use
xl:w-14
to set an element to a fixed width(3.5rem) at only extremely large screen sizes.Set the maximum width/height of an element using the
max-h-full
utilities.Use
overflow-y-auto
to allow vertical scrolling if needed.Control the background color of an element to white using the
bg-white
utilities.Use
overflow-y-scroll
to allow vertical scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.Use
sticky
to position an element asrelative
until it crosses a specified threshold, then treat it as fixed until its parent is off screen.Use the
top-0
utilities to set the top position of a positioned element to 0rem.Use
w-full
to set an element to a 100% based width.Control the background color of an element to opacity-100 using the
bg-opacity-100
utilities.Use
inline
utilities to put the element on its own line and fill its parent.Control the margin on left side of an element to 0.75rem using the
ml-3
utilities.Use
justify-start
to justify items against the start of the container’s main axis at only large screen sizes.Use
inline-block
utilities to wrap the element to prevent the text inside from extending beyond its parent.Control the background color of an element to blue-100 using the
bg-blue-100
utilities.Control the margin on left side of an element to 0.5rem using the
ml-2
utilities.Use the
right-6
utilities to set the right position of a positioned element to 1.5rem.Set the maximum width/height of an element using the
lg:max-w-md
utilities at only large screen sizes.Control the margin on left side of an element to -0.25rem at only large screen sizes using the
lg:-ml-1
utilities.Use
absolute
to position an element outside of the normal flow of the document at only large screen sizes, causing neighboring elements to act as if the element doesn’t exist.Control the padding on all sides of an element to 1rem using the
p-4
utilities.Control the margin on top side of an element to 1rem using the
mt-4
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the vertical padding of an element to 0.5rem using the
py-2
utilities.Control the text color of an element to white using the
text-white
utilities.Control the background color of an element to blue-500 using the
bg-blue-500
utilities.Control the background color of an element to blue-600 using the
hover:bg-blue-600
utilities on hover.Control the background color of an element to blue-700 using the
focus:bg-blue-700
utilities on focus.Use
h-72
to set an element to a fixed height(18rem).Control the background color of an element to blue-100 using the
hover:bg-blue-100
utilities on hover.Use
flex
to create a block-level flex container at only large screen sizes.Use
inline-flex
to create an inline flex container that flows with text.Use
w-3
to set an element to a fixed width(0.75rem).Use
h-3
to set an element to a fixed height(0.75rem).Control the text color of an element to gray-600 using the
text-gray-600
utilities.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.Set the maximum width/height of an element using the
max-w-lg
utilities.Control the vertical margin of an element to 0.5rem using the
my-2
utilities.Use
grid
to create a grid container.Use
grid
to create a grid container.To specify the width between columns, you can use the
gap-6
utilities.Control the vertical padding of an element to 0.25rem using the
py-1
utilities.Control the padding on all sides of an element to 0.25rem using the
p-1
utilities.Control the background color of an element to blue-200 using the
bg-blue-200
utilities.Control the margin on left side of an element to auto using the
ml-auto
utilities.Control the margin on right side of an element to 0.5rem using the
mr-2
utilities.Control the margin on right side of an element to 1.25rem at only large screen sizes using the
lg:mr-5
utilities.Use
w-5
to set an element to a fixed width(1.25rem).Use
h-5
to set an element to a fixed height(1.25rem).Control the background color of an element to red-600 using the
bg-red-600
utilities.Control the background color of an element to blue-300 using the
hover:bg-blue-300
utilities on hover.Control the background color of an element to opacity-20 using the
hover:bg-opacity-20
utilities on hover.Control the padding on all sides of an element to px using the
p-px
utilities.Control the border color of an element to 0.5rem using the
border-2
utilities.Control the border color of an element to blue-100 using the
border-blue-100
utilities.Use
w-11
to set an element to a fixed width(2.75rem).Use
h-11
to set an element to a fixed height(2.75rem).Set the left padding of the element to 0.5rem using the
pl-2
utilities classControl the padding on right side of an element to 0.5rem using the
pr-2
utilities.Control the padding on right side of an element to 1rem at only extremely large screen sizes using the
xl:pr-4
utilities.Control the padding on top side of an element to 0.5rem using the
pt-2
utilities.Control the text color of an element to 3xl using the
text-3xl
utilities.Control the text color of an element to xl using the
text-xl
utilities.Control the text color of an element to gray-500 using the
text-gray-500
utilities.Use
grid
to create a grid container.Use
grid
to create a grid container at only medium screen sizes.Use
h-32
to set an element to a fixed height(8rem).Control the vertical margin of an element to 1rem using the
my-4
utilities.Use
h-56
to set an element to a fixed height(14rem).Control the margin on bottom side of an element to 0.5rem using the
mb-2
utilities.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.Control the background color of an element to blue-400 using the
bg-blue-400
utilities.Control the stack order (or three-dimensional positioning) of an element to 30 in Tailwind, regardless of order it has been displayed, using the
z-30
utilities.Set the maximum width/height of an element using the
max-w-sm
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a Simple Dashboard Layout components, learn and follow along to implement your own components.