DevToolBoxGRATIS
Blog

Tailwind CSS Cheat Sheet: Guida di riferimento completa

15 min di letturadi DevToolBox

Tailwind CSS is a utility-first CSS framework that lets you build designs directly in your markup. Instead of writing custom CSS, you apply pre-built utility classes. This complete Tailwind CSS cheat sheet covers every major category of classes with their CSS output, so you can quickly look up any utility you need.

Why Tailwind CSS and Why a Cheat Sheet?

Tailwind CSS has hundreds of utility classes. While the naming convention is intuitive, having a quick-reference cheat sheet saves time and boosts productivity. This guide organizes all essential classes by category with exact CSS output.

Spacing: Padding & Margin

Tailwind uses a consistent spacing scale. The number after p- or m- maps to a rem value (multiply by 0.25rem). Negative margins use -m- prefix.

ClassCSS OutputValue
p-0padding: 0px0px
p-1padding: 0.25rem4px
p-2padding: 0.5rem8px
p-3padding: 0.75rem12px
p-4padding: 1rem16px
p-5padding: 1.25rem20px
p-6padding: 1.5rem24px
p-8padding: 2rem32px
p-10padding: 2.5rem40px
p-12padding: 3rem48px
p-16padding: 4rem64px
p-20padding: 5rem80px
p-24padding: 6rem96px
p-32padding: 8rem128px
p-40padding: 10rem160px
p-48padding: 12rem192px
p-64padding: 16rem256px
p-96padding: 24rem384px

Directional Padding & Margin

PrefixCSS PropertyDescription
p-*paddingAll sides
px-*padding-left + padding-rightHorizontal
py-*padding-top + padding-bottomVertical
pt-*padding-topTop
pr-*padding-rightRight
pb-*padding-bottomBottom
pl-*padding-leftLeft
m-*marginAll sides
mx-*margin-left + margin-rightHorizontal
my-*margin-top + margin-bottomVertical
-m-4margin: -1remNegative margin
m-automargin: autoAuto margin
<!-- Spacing examples -->
<div class="p-4">padding 1rem all sides</div>
<div class="px-6 py-3">horizontal 1.5rem, vertical 0.75rem</div>
<div class="mt-8 mb-4">top margin 2rem, bottom margin 1rem</div>
<div class="mx-auto max-w-lg">centered container</div>
<div class="-mt-4">negative top margin (overlap)</div>
<div class="space-x-4">children spaced 1rem horizontally</div>
<div class="space-y-2">children spaced 0.5rem vertically</div>

Typography

Tailwind provides utilities for font size, weight, line height, letter spacing, text alignment, and text color.

Font Size

ClassCSS OutputSize
text-xsfont-size: 0.75rem; line-height: 1rem12px
text-smfont-size: 0.875rem; line-height: 1.25rem14px
text-basefont-size: 1rem; line-height: 1.5rem16px
text-lgfont-size: 1.125rem; line-height: 1.75rem18px
text-xlfont-size: 1.25rem; line-height: 1.75rem20px
text-2xlfont-size: 1.5rem; line-height: 2rem24px
text-3xlfont-size: 1.875rem; line-height: 2.25rem30px
text-4xlfont-size: 2.25rem; line-height: 2.5rem36px
text-5xlfont-size: 3rem; line-height: 148px
text-6xlfont-size: 3.75rem; line-height: 160px
text-7xlfont-size: 4.5rem; line-height: 172px
text-8xlfont-size: 6rem; line-height: 196px
text-9xlfont-size: 8rem; line-height: 1128px

Font Weight

ClassCSS Output
font-thinfont-weight: 100
font-extralightfont-weight: 200
font-lightfont-weight: 300
font-normalfont-weight: 400
font-mediumfont-weight: 500
font-semiboldfont-weight: 600
font-boldfont-weight: 700
font-extraboldfont-weight: 800
font-blackfont-weight: 900

Line Height

ClassCSS Output
leading-noneline-height: 1
leading-tightline-height: 1.25
leading-snugline-height: 1.375
leading-normalline-height: 1.5
leading-relaxedline-height: 1.625
leading-looseline-height: 2
leading-3line-height: 0.75rem
leading-6line-height: 1.5rem
leading-8line-height: 2rem
leading-10line-height: 2.5rem

Letter Spacing

ClassCSS Output
tracking-tighterletter-spacing: -0.05em
tracking-tightletter-spacing: -0.025em
tracking-normalletter-spacing: 0em
tracking-wideletter-spacing: 0.025em
tracking-widerletter-spacing: 0.05em
tracking-widestletter-spacing: 0.1em

Text Alignment

ClassCSS Output
text-lefttext-align: left
text-centertext-align: center
text-righttext-align: right
text-justifytext-align: justify
text-starttext-align: start
text-endtext-align: end

Text Color

<!-- Text color examples -->
<p class="text-black">text-black → color: #000</p>
<p class="text-white">text-white → color: #fff</p>
<p class="text-gray-500">text-gray-500 → color: #6b7280</p>
<p class="text-red-600">text-red-600 → color: #dc2626</p>
<p class="text-blue-500">text-blue-500 → color: #3b82f6</p>
<p class="text-green-700">text-green-700 → color: #15803d</p>
<p class="text-transparent">text-transparent → color: transparent</p>
<p class="text-current">text-current → color: currentColor</p>

Colors

Tailwind uses a numeric color scale from 50 (lightest) to 950 (darkest). Colors are applied with prefixes: bg- for background, text- for text, and border- for borders.

Shadebg-blue-*Hex ValueUsage
50bg-blue-50#eff6ffLightest background
100bg-blue-100#dbeafeLight background
200bg-blue-200#bfdbfeHover states, light borders
300bg-blue-300#93c5fdActive states
400bg-blue-400#60a5faIcons, secondary elements
500bg-blue-500#3b82f6Primary brand color
600bg-blue-600#2563ebPrimary buttons, links
700bg-blue-700#1d4ed8Hover on primary
800bg-blue-800#1e40afDark accents
900bg-blue-900#1e3a8aDarkest accent
950bg-blue-950#172554Near-black backgrounds

Color Prefixes

PrefixCSS PropertyExample
bg-*background-colorbg-red-500
text-*colortext-blue-600
border-*border-colorborder-gray-300
ring-*box-shadow (ring)ring-indigo-500
divide-*border-color (dividers)divide-gray-200
placeholder-*placeholder colorplaceholder-gray-400
from-*gradient startfrom-purple-500
via-*gradient middlevia-pink-500
to-*gradient endto-red-500
<!-- Available color palettes -->
slate, gray, zinc, neutral, stone    <!-- Grays -->
red, orange, amber, yellow           <!-- Warm -->
lime, green, emerald, teal           <!-- Green -->
cyan, sky, blue, indigo              <!-- Blue -->
violet, purple, fuchsia, pink, rose  <!-- Purple/Pink -->

<!-- Gradient example -->
<div class="bg-gradient-to-r from-blue-500 via-purple-500 to-pink-500">
  Gradient background
</div>

Flexbox

Tailwind provides comprehensive flexbox utilities for building flexible layouts.

ClassCSS Output
flexdisplay: flex
inline-flexdisplay: inline-flex
flex-rowflex-direction: row
flex-row-reverseflex-direction: row-reverse
flex-colflex-direction: column
flex-col-reverseflex-direction: column-reverse
flex-wrapflex-wrap: wrap
flex-wrap-reverseflex-wrap: wrap-reverse
flex-nowrapflex-wrap: nowrap
flex-1flex: 1 1 0%
flex-autoflex: 1 1 auto
flex-initialflex: 0 1 auto
flex-noneflex: none

Justify & Align

ClassCSS Output
justify-startjustify-content: flex-start
justify-endjustify-content: flex-end
justify-centerjustify-content: center
justify-betweenjustify-content: space-between
justify-aroundjustify-content: space-around
justify-evenlyjustify-content: space-evenly
items-startalign-items: flex-start
items-endalign-items: flex-end
items-centeralign-items: center
items-baselinealign-items: baseline
items-stretchalign-items: stretch

Gap

ClassCSS Output
gap-0gap: 0px
gap-1gap: 0.25rem (4px)
gap-2gap: 0.5rem (8px)
gap-4gap: 1rem (16px)
gap-6gap: 1.5rem (24px)
gap-8gap: 2rem (32px)
gap-x-4column-gap: 1rem
gap-y-4row-gap: 1rem
<!-- Flexbox layout examples -->
<!-- Centered content -->
<div class="flex items-center justify-center h-screen">
  <div>Perfectly centered</div>
</div>

<!-- Navbar: logo left, links right -->
<nav class="flex justify-between items-center p-4">
  <div class="text-xl font-bold">Logo</div>
  <div class="flex gap-4">
    <a href="#">Home</a>
    <a href="#">About</a>
    <a href="#">Contact</a>
  </div>
</nav>

<!-- Responsive cards -->
<div class="flex flex-wrap gap-4">
  <div class="flex-1 min-w-[300px]">Card 1</div>
  <div class="flex-1 min-w-[300px]">Card 2</div>
  <div class="flex-1 min-w-[300px]">Card 3</div>
</div>

Grid

CSS Grid utilities for creating two-dimensional layouts.

ClassCSS Output
griddisplay: grid
grid-cols-1grid-template-columns: repeat(1, minmax(0, 1fr))
grid-cols-2grid-template-columns: repeat(2, minmax(0, 1fr))
grid-cols-3grid-template-columns: repeat(3, minmax(0, 1fr))
grid-cols-4grid-template-columns: repeat(4, minmax(0, 1fr))
grid-cols-6grid-template-columns: repeat(6, minmax(0, 1fr))
grid-cols-12grid-template-columns: repeat(12, minmax(0, 1fr))
grid-cols-nonegrid-template-columns: none
grid-rows-1grid-template-rows: repeat(1, minmax(0, 1fr))
grid-rows-3grid-template-rows: repeat(3, minmax(0, 1fr))
grid-rows-6grid-template-rows: repeat(6, minmax(0, 1fr))

Column & Row Span

ClassCSS Output
col-span-1grid-column: span 1 / span 1
col-span-2grid-column: span 2 / span 2
col-span-3grid-column: span 3 / span 3
col-span-4grid-column: span 4 / span 4
col-span-6grid-column: span 6 / span 6
col-span-fullgrid-column: 1 / -1
row-span-1grid-row: span 1 / span 1
row-span-2grid-row: span 2 / span 2
row-span-3grid-row: span 3 / span 3
row-span-fullgrid-row: 1 / -1
auto-cols-autogrid-auto-columns: auto
auto-cols-frgrid-auto-columns: minmax(0, 1fr)
auto-rows-autogrid-auto-rows: auto
auto-rows-frgrid-auto-rows: minmax(0, 1fr)
<!-- Grid layout examples -->
<!-- 3-column grid -->
<div class="grid grid-cols-3 gap-4">
  <div>1</div>  <div>2</div>  <div>3</div>
  <div>4</div>  <div>5</div>  <div>6</div>
</div>

<!-- Responsive grid: 1 col mobile, 2 tablet, 3 desktop -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
  <div>Card 1</div>
  <div>Card 2</div>
  <div>Card 3</div>
</div>

<!-- Dashboard layout with spanning -->
<div class="grid grid-cols-4 gap-4">
  <div class="col-span-4">Header (full width)</div>
  <div class="col-span-1">Sidebar</div>
  <div class="col-span-3">Main content</div>
  <div class="col-span-2">Half width</div>
  <div class="col-span-2">Half width</div>
</div>

Layout: Width, Height & Container

Utilities for controlling element dimensions and layout containers.

ClassCSS Output
w-0width: 0px
w-1width: 0.25rem (4px)
w-4width: 1rem (16px)
w-8width: 2rem (32px)
w-16width: 4rem (64px)
w-32width: 8rem (128px)
w-64width: 16rem (256px)
w-1/2width: 50%
w-1/3width: 33.333%
w-2/3width: 66.667%
w-1/4width: 25%
w-3/4width: 75%
w-fullwidth: 100%
w-screenwidth: 100vw
w-autowidth: auto
w-fitwidth: fit-content
w-minwidth: min-content
w-maxwidth: max-content

Height & Max/Min

ClassCSS Output
h-0height: 0px
h-4height: 1rem (16px)
h-16height: 4rem (64px)
h-64height: 16rem (256px)
h-fullheight: 100%
h-screenheight: 100vh
h-autoheight: auto
min-h-0min-height: 0px
min-h-fullmin-height: 100%
min-h-screenmin-height: 100vh
max-w-smmax-width: 24rem (384px)
max-w-mdmax-width: 28rem (448px)
max-w-lgmax-width: 32rem (512px)
max-w-xlmax-width: 36rem (576px)
max-w-2xlmax-width: 42rem (672px)
max-w-4xlmax-width: 56rem (896px)
max-w-6xlmax-width: 72rem (1152px)
max-w-7xlmax-width: 80rem (1280px)
max-w-fullmax-width: 100%
max-w-nonemax-width: none
containerwidth: 100% (responsive max-width)
<!-- Layout examples -->
<div class="container mx-auto px-4">
  Centered responsive container
</div>

<div class="max-w-2xl mx-auto">
  Max-width 672px, centered
</div>

<div class="w-full h-screen">
  Full width, full viewport height
</div>

<div class="min-h-screen flex flex-col">
  <main class="flex-1">Content</main>
  <footer>Footer always at bottom</footer>
</div>

Borders & Rounded Corners

Utilities for border width, style, radius, and ring (outline) effects.

ClassCSS Output
borderborder-width: 1px
border-0border-width: 0px
border-2border-width: 2px
border-4border-width: 4px
border-8border-width: 8px
border-tborder-top-width: 1px
border-r-2border-right-width: 2px
border-b-4border-bottom-width: 4px
border-lborder-left-width: 1px
border-solidborder-style: solid
border-dashedborder-style: dashed
border-dottedborder-style: dotted
border-noneborder-style: none

Border Radius

ClassCSS Output
rounded-noneborder-radius: 0px
rounded-smborder-radius: 0.125rem (2px)
roundedborder-radius: 0.25rem (4px)
rounded-mdborder-radius: 0.375rem (6px)
rounded-lgborder-radius: 0.5rem (8px)
rounded-xlborder-radius: 0.75rem (12px)
rounded-2xlborder-radius: 1rem (16px)
rounded-3xlborder-radius: 1.5rem (24px)
rounded-fullborder-radius: 9999px
rounded-t-lgborder-top-left/right-radius: 0.5rem
rounded-b-lgborder-bottom-left/right-radius: 0.5rem

Ring (Outline)

ClassCSS Output
ring-0box-shadow: 0 0 0 0px ...
ring-1box-shadow: 0 0 0 1px ...
ring-2box-shadow: 0 0 0 2px ...
ring-4box-shadow: 0 0 0 4px ...
ringbox-shadow: 0 0 0 3px ...
ring-insetbox-shadow: inset ...
ring-blue-500ring color: #3b82f6
ring-offset-2ring offset: 2px
ring-offset-whitering offset color: #fff

Shadows & Effects

Utilities for box shadows, opacity, and blur effects.

ClassCSS Output
shadow-smbox-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05)
shadowbox-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)
shadow-mdbox-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1)
shadow-lgbox-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1)
shadow-xlbox-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1)
shadow-2xlbox-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25)
shadow-innerbox-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05)
shadow-nonebox-shadow: 0 0 #0000

Opacity & Blur

ClassCSS Output
opacity-0opacity: 0
opacity-25opacity: 0.25
opacity-50opacity: 0.5
opacity-75opacity: 0.75
opacity-100opacity: 1
blur-nonefilter: blur(0)
blur-smfilter: blur(4px)
blurfilter: blur(8px)
blur-mdfilter: blur(12px)
blur-lgfilter: blur(16px)
blur-xlfilter: blur(24px)
blur-2xlfilter: blur(40px)
blur-3xlfilter: blur(64px)
backdrop-blur-smbackdrop-filter: blur(4px)
backdrop-blurbackdrop-filter: blur(8px)
backdrop-blur-mdbackdrop-filter: blur(12px)
backdrop-blur-lgbackdrop-filter: blur(16px)
backdrop-blur-xlbackdrop-filter: blur(24px)

Transitions & Animation

Utilities for CSS transitions and keyframe animations.

ClassCSS Output
transition-nonetransition-property: none
transition-alltransition-property: all
transitiontransition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter
transition-colorstransition-property: color, background-color, border-color, text-decoration-color, fill, stroke
transition-opacitytransition-property: opacity
transition-shadowtransition-property: box-shadow
transition-transformtransition-property: transform

Duration & Easing

ClassCSS Output
duration-75transition-duration: 75ms
duration-100transition-duration: 100ms
duration-150transition-duration: 150ms
duration-200transition-duration: 200ms
duration-300transition-duration: 300ms
duration-500transition-duration: 500ms
duration-700transition-duration: 700ms
duration-1000transition-duration: 1000ms
ease-lineartransition-timing-function: linear
ease-intransition-timing-function: cubic-bezier(0.4, 0, 1, 1)
ease-outtransition-timing-function: cubic-bezier(0, 0, 0.2, 1)
ease-in-outtransition-timing-function: cubic-bezier(0.4, 0, 0.2, 1)

Animations

ClassDescription
animate-noneNo animation
animate-spinContinuous rotation (loading spinners)
animate-pingScale + fade out (notification dot)
animate-pulseGentle fade in/out (skeleton loaders)
animate-bounceBouncing motion (scroll indicator)
<!-- Transition examples -->
<button class="bg-blue-500 hover:bg-blue-700 transition-colors duration-200">
  Smooth color change on hover
</button>

<div class="hover:scale-105 transition-transform duration-300 ease-out">
  Scale up on hover
</div>

<div class="hover:shadow-xl transition-shadow duration-300">
  Shadow appears on hover
</div>

<!-- Animation examples -->
<svg class="animate-spin h-5 w-5">...</svg>  <!-- Loading spinner -->
<span class="animate-ping absolute">...</span> <!-- Notification dot -->
<div class="animate-pulse bg-gray-300 h-4 rounded">...</div> <!-- Skeleton -->

Responsive Prefixes

Tailwind uses mobile-first responsive design. Prefix any utility with a breakpoint to apply it at that screen size and above.

PrefixMin WidthCSS Media Query
(none)0pxNo media query (applies to all)
sm:640px@media (min-width: 640px) { ... }
md:768px@media (min-width: 768px) { ... }
lg:1024px@media (min-width: 1024px) { ... }
xl:1280px@media (min-width: 1280px) { ... }
2xl:1536px@media (min-width: 1536px) { ... }
<!-- Mobile-first responsive design -->

<!-- Stack on mobile, side-by-side on tablet+ -->
<div class="flex flex-col md:flex-row gap-4">
  <div class="w-full md:w-1/3">Sidebar</div>
  <div class="w-full md:w-2/3">Main</div>
</div>

<!-- Responsive text size -->
<h1 class="text-2xl sm:text-3xl md:text-4xl lg:text-5xl">
  Responsive Heading
</h1>

<!-- Responsive grid columns -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
  <div>Card</div>
  <div>Card</div>
  <div>Card</div>
  <div>Card</div>
</div>

<!-- Hide/show at breakpoints -->
<div class="hidden md:block">Visible on md and above</div>
<div class="block md:hidden">Visible only below md</div>

<!-- Responsive padding -->
<div class="p-4 sm:p-6 md:p-8 lg:p-12">
  Padding grows with screen size
</div>

State Variants

Apply styles conditionally using state variant prefixes.

VariantCSS Selector / ConditionExample
hover::hoverhover:bg-blue-700
focus::focusfocus:outline-none focus:ring-2
focus-within::focus-withinfocus-within:border-blue-500
focus-visible::focus-visiblefocus-visible:ring-2
active::activeactive:bg-blue-800
disabled::disableddisabled:opacity-50
visited::visitedvisited:text-purple-600
first::first-childfirst:mt-0
last::last-childlast:mb-0
odd::nth-child(odd)odd:bg-gray-100
even::nth-child(even)even:bg-gray-50
group-hover:.group:hover &group-hover:text-white
peer-focus:.peer:focus ~ &peer-focus:text-blue-500
dark:prefers-color-scheme: darkdark:bg-gray-900
placeholder:::placeholderplaceholder:text-gray-400
before:::beforebefore:content-[""]
after:::afterafter:content-[""]
<!-- State variant examples -->

<!-- Button with multiple states -->
<button class="bg-blue-500 hover:bg-blue-700 active:bg-blue-800
               focus:outline-none focus:ring-2 focus:ring-blue-300
               disabled:opacity-50 disabled:cursor-not-allowed
               transition-colors duration-200">
  Click me
</button>

<!-- Group hover: parent hover affects child -->
<div class="group p-4 hover:bg-blue-50 rounded-lg">
  <h3 class="group-hover:text-blue-600">Title</h3>
  <p class="group-hover:text-blue-400">Description</p>
</div>

<!-- Dark mode -->
<div class="bg-white dark:bg-gray-900 text-black dark:text-white">
  Adapts to light/dark mode
</div>

<!-- Peer: input state affects sibling -->
<input class="peer" type="text" placeholder="Email" />
<p class="invisible peer-invalid:visible text-red-500">
  Invalid email address
</p>

Tips & Advanced Usage

Power-user features for when the built-in utilities are not enough.

Arbitrary Values

Use square brackets to specify any custom value:

<!-- Arbitrary values with square brackets -->
<div class="w-[120px]">width: 120px</div>
<div class="h-[calc(100vh-80px)]">height: calc(100vh - 80px)</div>
<div class="bg-[#1a2b3c]">background: #1a2b3c</div>
<div class="text-[22px]">font-size: 22px</div>
<div class="grid-cols-[200px_1fr_200px]">custom grid template</div>
<div class="p-[clamp(1rem,3vw,3rem)]">responsive clamp padding</div>
<div class="text-[color:var(--brand)]">CSS variable color</div>
<div class="top-[var(--header-h)]">CSS variable position</div>

Important Modifier

Prefix any utility with ! to add !important:

<!-- Important modifier with ! prefix -->
<div class="!p-4">padding: 1rem !important</div>
<div class="!mt-0">margin-top: 0 !important</div>
<div class="!text-red-500">color: #ef4444 !important</div>

<!-- Useful for overriding third-party styles -->
<div class="external-widget !bg-transparent !border-none">
  Override library styles
</div>

@apply Directive

Extract repeated utility patterns into custom CSS classes:

/* In your CSS file — use @apply to extract components */
.btn {
  @apply px-4 py-2 rounded-lg font-semibold transition-colors duration-200;
}

.btn-primary {
  @apply btn bg-blue-500 text-white hover:bg-blue-700;
}

.btn-secondary {
  @apply btn bg-gray-200 text-gray-800 hover:bg-gray-300;
}

.input {
  @apply w-full px-3 py-2 border border-gray-300 rounded-md
         focus:outline-none focus:ring-2 focus:ring-blue-500
         focus:border-transparent;
}

.card {
  @apply bg-white dark:bg-gray-800 rounded-xl shadow-md p-6
         hover:shadow-lg transition-shadow duration-300;
}

/* Note: Tailwind recommends using utilities directly in HTML
   and only extracting with @apply for truly repeated patterns. */

Frequently Asked Questions

What is the difference between Tailwind CSS and regular CSS?

Tailwind CSS is a utility-first framework that provides pre-built CSS classes you apply directly in HTML. Unlike regular CSS where you write custom stylesheets, Tailwind lets you style elements inline using class names like p-4, text-lg, and bg-blue-500. This approach eliminates the need to switch between HTML and CSS files and avoids naming CSS classes.

How does the Tailwind CSS spacing scale work?

Tailwind uses a consistent spacing scale where each unit equals 0.25rem (4px). So p-1 is 0.25rem (4px), p-2 is 0.5rem (8px), p-4 is 1rem (16px), and so on. The scale goes from 0 to 96 (24rem/384px). You can also use arbitrary values like p-[13px] for custom spacing.

How do responsive breakpoints work in Tailwind CSS?

Tailwind uses a mobile-first approach. Unprefixed utilities apply to all screen sizes. Prefixed utilities like md:flex only apply at that breakpoint and above. The default breakpoints are sm (640px), md (768px), lg (1024px), xl (1280px), and 2xl (1536px). You stack prefixes to create responsive designs, e.g., w-full md:w-1/2 lg:w-1/3.

Can I use custom colors in Tailwind CSS?

Yes. You can extend the default color palette in tailwind.config.js under theme.extend.colors. You can also use arbitrary values like bg-[#1a2b3c] or text-[rgb(255,100,50)] directly in your markup for one-off colors without modifying the config.

What is the @apply directive and when should I use it?

The @apply directive lets you extract repeated utility patterns into custom CSS classes. For example, if you use "px-4 py-2 bg-blue-500 text-white rounded" on many buttons, you can create a .btn class with @apply. Use it sparingly - Tailwind recommends using utilities directly and only extracting components when you have true duplication across many files.

How do I make Tailwind CSS work with dark mode?

Tailwind supports dark mode via the dark: variant. Prefix any utility with dark: to apply it when dark mode is active, e.g., bg-white dark:bg-gray-900. Configure dark mode strategy in tailwind.config.js as "media" (follows OS preference) or "class" (toggle via a class on the html element).

𝕏 Twitterin LinkedIn
È stato utile?

Resta aggiornato

Ricevi consigli dev e nuovi strumenti ogni settimana.

Niente spam. Cancella quando vuoi.

Prova questi strumenti correlati

TWCSS to TailwindTWTailwind CSS Color Picker📐Flexbox Generator

Articoli correlati

Cheat Sheet CSS Flexbox: Ogni proprietà spiegata con esempi

Cheat sheet visuale CSS Flexbox con tutte le proprietà ed esempi.

Migrare da CSS a Tailwind: Una guida pratica

Guida passo dopo passo per migrare dal CSS tradizionale a Tailwind CSS. Mapping delle utility, responsive design, temi personalizzati e suggerimenti sulle prestazioni.