Tailwind CSS Cheat Sheet

Tailwind CSS is a utility-first CSS framework that helps developers create responsive and customizable user interfaces with ease. It provides a set of pre-defined classes that can be used to style HTML elements, making it easier to create complex layouts and designs without writing custom CSS code.

One of the key benefits of Tailwind CSS is its flexibility. It allows developers to customize the framework to suit their specific needs, by adding or removing classes, changing colors, and adjusting spacing and typography. This makes it a great choice for projects of all sizes, from small websites to large-scale applications.

Another advantage of Tailwind CSS is its focus on accessibility. The framework includes built-in support for screen readers and other assistive technologies, making it easier to create websites and applications that are accessible to all users.

Tailwind CSS is also designed to be easy to learn and use. Its documentation is comprehensive and well-organized, with clear examples and explanations of each class and feature. Additionally, the framework includes a range of tools and plugins that can help streamline the development process, such as a CSS purge tool that removes unused styles from the final build.

Colors

ClassDescription
text-{color}Sets the text color to the specified color
bg-{color}Sets the background color to the specified color
border-{color}Sets the border color to the specified color
hover:text-{color}Sets the text color to the specified color on hover
hover:bg-{color}Sets the background color to the specified color on hover
hover:border-{color}Sets the border color to the specified color on hover

Typography

ClassDescription
text-{size}Sets the font size to the specified size
font-{family}Sets the font family to the specified family
font-boldSets the font weight to bold
italicSets the font style to italic
uppercaseSets the text to uppercase
lowercaseSets the text to lowercase
capitalizeSets the first letter of each word to uppercase
text-leftAligns the text to the left
text-centerAligns the text to the center
text-rightAligns the text to the right

Spacing

ClassDescription
m-{size}Sets the margin to the specified size
p-{size}Sets the padding to the specified size
m-autoCenters the element horizontally
my-{size}Sets the vertical margin to the specified size
mx-{size}Sets the horizontal margin to the specified size
py-{size}Sets the vertical padding to the specified size
px-{size}Sets the horizontal padding to the specified size

Layout

ClassDescription
w-{size}Sets the width to the specified size
h-{size}Sets the height to the specified size
max-w-{size}Sets the maximum width to the specified size
max-h-{size}Sets the maximum height to the specified size
min-w-{size}Sets the minimum width to the specified size
min-h-{size}Sets the minimum height to the specified size
flexEnables flexbox layout
flex-rowSets the flex direction to row
flex-colSets the flex direction to column
justify-startAligns items to the start of the container
justify-endAligns items to the end of the container
justify-centerCenters items horizontally
justify-betweenDistributes items evenly with space between
justify-aroundDistributes items evenly with space around
items-startAligns items to the start of the container
items-endAligns items to the end of the container
items-centerCenters items vertically
items-baselineAligns items to their baseline
items-stretchStretches items to fill the container
self-startAligns the item to the start of the container
self-endAligns the item to the end of the container
self-centerCenters the item vertically
self-baselineAligns the item to its baseline
self-stretchStretches the item to fill the container

Borders

ClassDescription
borderAdds a border to the element
border-{size}Sets the border width to the specified size
roundedAdds rounded corners to the element
rounded-{size}Sets the border radius to the specified size
border-solidSets the border style to solid
border-dashedSets the border style to dashed
border-dottedSets the border style to dotted
border-doubleSets the border style to double
border-noneRemoves the border from the element

Backgrounds

ClassDescription
bg-{color}Sets the background color to the specified color
bg-opacity-{value}Sets the background opacity to the specified value
bg-fixedSets the background to fixed
bg-localSets the background to local
bg-scrollSets the background to scroll
bg-repeatSets the background to repeat
bg-no-repeatSets the background to not repeat
bg-coverSets the background to cover
bg-containSets the background to contain

Effects

ClassDescription
shadowAdds a shadow to the element
shadow-{size}Sets the shadow size to the specified size
opacity-{value}Sets the opacity to the specified value
hover:opacity-{value}Sets the opacity to the specified value on hover
transition-{property} {duration} {timing-function}Sets the transition property, duration, and timing function

Utilities

ClassDescription
hiddenHides the element
invisibleMakes the element invisible
cursor-{type}Sets the cursor type
pointer-events-{type}Sets the pointer events type
select-noneDisables text selection
select-textEnables text selection
overflow-{type}Sets the overflow type
z-{index}Sets the z-index
staticSets the position to static
fixedSets the position to fixed
absoluteSets the position to absolute
relativeSets the position to relative
stickySets the position to sticky
top-{size}Sets the top position to the specified size
bottom-{size}Sets the bottom position to the specified size
left-{size}Sets the left position to the specified size
right-{size}Sets the right position to the specified size
transform-{type}Applies a transformation
scale-{value}Scales the element
rotate-{value}Rotates the element
translate-x-{value}Translates the element horizontally
translate-y-{value}Translates the element vertically
skew-x-{value}Skews the element horizontally
skew-y-{value}Skews the element vertically

Reference:

https://v2.tailwindcss.com/docs