Tailwind CSS is a utility-first CSS framework that provides low-level utility classes to build designs directly in your markup. Here’s a cheat sheet to get you started with Tailwind CSS:
Layout
- Margin and Padding:
m-{size}
: Marginp-{size}
: Paddingm-auto
: Margin auto
- Width and Height:
w-{size}
: Widthh-{size}
: Heightmax-w-{size}
: Maximum widthmax-h-{size}
: Maximum height
- Flexbox:
flex
: Enable flex containerflex-{value}
: Flex propertyjustify-{value}
: Justify contentitems-{value}
: Align items
- Grid:
grid
: Enable grid containercol-{value}
: Column span
Typography
- Text Color and Size:
text-{color}
: Text colortext-{size}
: Text size
- Font Weight:
font-{weight}
: Font weight
- Line Height:
leading-{size}
: Line height
Backgrounds
- Background Color:
bg-{color}
: Background color
- Background Image:
bg-{image}
: Background image
Borders
- Border:
border
: Add borderborder-{side}
: Border on specific siderounded
: Apply border-radius
- Border Color and Width:
border-{color}
: Border colorborder-{width}
: Border width
Shadows
- Box Shadow:
shadow
: Apply box shadow
Interactivity
- Hover and Focus:
hover:{property}
: Apply on hoverfocus:{property}
: Apply on focus
- Cursor:
cursor-{type}
: Change cursor type
Utilities
- Visibility:
invisible
: Hide elementvisible
: Show element
- Overflow:
overflow-{type}
: Set overflow behavior
- Positioning:
static
,relative
,absolute
,fixed
: Position values
- Z-Index:
z-{index}
: Set z-index
Responsive Design
- Responsive Prefixes:
sm:
,md:
,lg:
,xl:
: Apply styles based on screen size
Flexbox and Grid
- Flex Container:
flex
,inline-flex
: Set display property
- Grid Columns:
grid-cols-{value}
: Set number of grid columns
Tailwind provides a large set of classes, and you can customize it further by configuring your tailwind.config.js
file. For detailed information, refer to the official Tailwind CSS documentation.