A comprehensive cheatsheet for Tailwind CSS utility classes, perfect for quick reference during development. This guide includes commonly used utilities, responsive design patterns, and best practices for building modern user interfaces.
TODO: Add comprehensive installation guide
# Install Tailwind CSS
npm install -D tailwindcss
# Initialize configuration file
npx tailwindcss init
// tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [],
}
block
- Block elementinline
- Inline elementinline-block
- Inline-block elementflex
- Flex containerinline-flex
- Inline flex containergrid
- Grid containerhidden
- Hide elementflex-row
- Direction: left to rightflex-col
- Direction: top to bottomflex-wrap
- Allow wrappingflex-nowrap
- Prevent wrappingjustify-start
- Justify: startjustify-end
- Justify: endjustify-center
- Justify: centerjustify-between
- Justify: space betweenitems-start
- Align items: startitems-center
- Align items: centeritems-end
- Align items: endgrid-cols-{1-12}
- Number of columnsgap-{size}
- Gap between grid itemscol-span-{1-12}
- Column spanrow-span-{1-6}
- Row spanm-{size}
- All sidesmt-{size}
- Topmr-{size}
- Rightmb-{size}
- Bottomml-{size}
- Leftmx-{size}
- Horizontalmy-{size}
- Verticalp-{size}
- All sidespt-{size}
- Toppr-{size}
- Rightpb-{size}
- Bottompl-{size}
- Leftpx-{size}
- Horizontalpy-{size}
- VerticalSize values: 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 96
text-xs
- 0.75remtext-sm
- 0.875remtext-base
- 1remtext-lg
- 1.125remtext-xl
- 1.25remtext-2xl
- 1.5remtext-3xl
- 1.875remtext-4xl
- 2.25remtext-5xl
- 3remfont-thin
- 100font-extralight
- 200font-light
- 300font-normal
- 400font-medium
- 500font-semibold
- 600font-bold
- 700font-extrabold
- 800font-black
- 900text-left
- Left aligntext-center
- Center aligntext-right
- Right aligntext-justify
- Justify texttext-{color}-{shade}
- Text colortext-blue-500
, text-red-700
bg-{color}-{shade}
- Background colorbg-gray-100
, bg-blue-500
bg-auto
- Auto sizebg-cover
- Coverbg-contain
- Containbg-center
- Centerbg-top
- Topbg-bottom
- Bottombg-left
- Leftbg-right
- Rightborder
- 1pxborder-0
- 0pxborder-2
- 2pxborder-4
- 4pxborder-8
- 8pxborder-{color}-{shade}
- Border colorborder-gray-200
, border-blue-500
rounded
- 0.25remrounded-sm
- 0.125remrounded-md
- 0.375remrounded-lg
- 0.5remrounded-xl
- 0.75remrounded-2xl
- 1remrounded-full
- 9999pxopacity-0
- 0opacity-25
- 0.25opacity-50
- 0.5opacity-75
- 0.75opacity-100
- 1shadow-sm
- Smallshadow
- Defaultshadow-md
- Mediumshadow-lg
- Largeshadow-xl
- Extra largeshadow-2xl
- 2x extra largeshadow-none
- Nonecursor-pointer
- Pointercursor-default
- Defaultcursor-not-allowed
- Not allowedselect-none
- Prevent selectionselect-text
- Allow selectionselect-all
- Select allhover:
or focus:
prefix to any utilityhover:bg-blue-700
, focus:outline-none
sm:
- 640pxmd:
- 768pxlg:
- 1024pxxl:
- 1280px2xl:
- 1536pxExample: md:flex-col
will apply flex-col at medium screens and above
Available colors with their shade variants (50-900):
gray
red
yellow
green
blue
indigo
purple
pink
Shade values:
Combining Utilities
<div class="flex items-center justify-between p-4 bg-blue-500 text-white">
Responsive Design
<div class="w-full md:w-1/2 lg:w-1/3">
State Variants
<button class="bg-blue-500 hover:bg-blue-700 focus:outline-none">
Custom Values
<div class="top-[117px]">
Organization
TODO: Add frequently used UI patterns with code examples
tailwind-cheatsheet/
āāā README.md
āāā LICENSE
āāā CONTRIBUTING.md
āāā examples/
ā āāā components/
ā ā āāā buttons.md
ā ā āāā cards.md
ā ā āāā forms.md
ā ā āāā navigation.md
ā āāā layouts/
ā āāā grid-systems.md
ā āāā hero-sections.md
ā āāā responsive-patterns.md
āāā docs/
āāā installation.md
āāā configuration.md
āāā customization.md
I welcome contributions! Please see the Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.