AI Generate TailwindCSS docs instantly

TailwindCSS Cheat Sheet

Quick reference guide with copy-paste ready code snippets

Try DocuWriter Free

Layout

4 snippets

Flexbox, grid, and positioning

Flexbox

<div class="flex items-center justify-between gap-4">
  <div class="flex-1">Left</div>
  <div class="flex-shrink-0">Right</div>
</div>

<div class="flex flex-col md:flex-row gap-6">

Grid

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
  <div class="col-span-2">Wide</div>
  <div>Normal</div>
</div>

Container

<div class="container mx-auto px-4 max-w-7xl">
  <!-- Centered content -->
</div>

Position

<div class="relative">
  <div class="absolute top-0 right-0">Badge</div>
  <div class="sticky top-4">Sidebar</div>
  <div class="fixed bottom-4 right-4">FAB</div>
</div>

Spacing & Sizing

2 snippets

Padding, margin, width, height

Padding & Margin

p-4    /* 1rem all sides */
px-6   /* 1.5rem horizontal */
py-2   /* 0.5rem vertical */
mt-8   /* 2rem top margin */
mx-auto /* center horizontally */
space-y-4 /* gap between children */

Width & Height

w-full   /* 100% */
w-1/2    /* 50% */
w-screen /* 100vw */
max-w-lg /* 32rem */
h-64     /* 16rem */
min-h-screen /* 100vh */
aspect-video /* 16/9 */

Typography

2 snippets

Font, text, and color

Font

text-sm / text-base / text-lg / text-xl / text-2xl
font-light / font-normal / font-medium / font-semibold / font-bold
leading-tight / leading-relaxed
tracking-wide

Text

text-gray-900 dark:text-gray-100
text-center / text-left / text-right
truncate          /* overflow ellipsis */
line-clamp-3      /* max 3 lines */
underline decoration-2 decoration-blue-500

Tired of looking up syntax?

DocuWriter.ai generates documentation and explains code using AI.

Try Free

Colors & Backgrounds

2 snippets

Color utilities and gradients

Background

bg-white dark:bg-gray-900
bg-blue-500 hover:bg-blue-600
bg-opacity-75
bg-gradient-to-r from-blue-500 to-purple-600

Opacity & Blend

opacity-50
bg-black/50      /* bg with 50% opacity */
text-white/80    /* text with 80% opacity */
mix-blend-multiply

Borders & Effects

2 snippets

Rounded, shadow, ring

Border & Rounded

border border-gray-200
border-b-2 border-blue-500
rounded-lg / rounded-full / rounded-none
divide-y divide-gray-200

Shadow & Ring

shadow-sm / shadow / shadow-md / shadow-lg / shadow-xl
ring-2 ring-blue-500 ring-offset-2
outline-none focus:ring-2 focus:ring-blue-500

Responsive

2 snippets

Breakpoints and adaptive design

Breakpoints

sm:  /* >= 640px  */
md:  /* >= 768px  */
lg:  /* >= 1024px */
xl:  /* >= 1280px */
2xl: /* >= 1536px */

<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4">

Show/Hide

<div class="hidden md:block">Desktop only</div>
<div class="md:hidden">Mobile only</div>

States & Dark Mode

2 snippets

Hover, focus, dark variants

Interactive States

hover:bg-blue-600
focus:outline-none focus:ring-2
active:scale-95
disabled:opacity-50 disabled:cursor-not-allowed
group-hover:visible
peer-invalid:text-red-500

Dark Mode

<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100">
  <p class="text-gray-600 dark:text-gray-400">Subtitle</p>
</div>

Animations & Transitions

2 snippets

Motion utilities

Transition

transition duration-300 ease-in-out
hover:scale-105 transition-transform
transition-colors duration-200
transition-opacity

Animate

animate-spin     /* loading spinner */
animate-ping     /* notification dot */
animate-pulse    /* skeleton loader */
animate-bounce   /* scroll indicator */

More Cheat Sheets

FAQ

Frequently asked questions

What is a TailwindCSS cheat sheet?

A TailwindCSS cheat sheet is a quick reference guide containing the most commonly used syntax, functions, and patterns in TailwindCSS. It helps developers quickly look up syntax without searching through documentation.

How do I learn TailwindCSS quickly?

Start with the basics: variables, control flow, and functions. Use this cheat sheet as a reference while practicing. For faster learning, try DocuWriter.ai to automatically explain code and generate documentation as you learn.

What are the most important TailwindCSS concepts?

Key TailwindCSS concepts include variables and data types, control flow (if/else, loops), functions, error handling, and working with data structures like arrays and objects/dictionaries.

How can I document my TailwindCSS code?

Use inline comments for complex logic, docstrings for functions and classes, and README files for projects. DocuWriter.ai can automatically generate professional documentation from your TailwindCSS code using AI.

Related resources

Stop memorizing. Start shipping.

Generate TailwindCSS Docs with AI

DocuWriter.ai automatically generates comments, docstrings, and README files for your code.

Auto-generate comments
Create README files
Explain complex code
API documentation
Start Free - No Credit Card

Join 33,700+ developers saving hours every week