Tailwind CSS cheat sheet
Dan Counsell · Founder of Realmac SoftwareUpdated
We’ve made RapidWeaver, a website builder for Mac, since 2004. Each guide works with any tool, then shows how in RapidWeaver Elements.
Bookmark this page. It covers the Tailwind CSS classes that do most of the work on a typical website. The full list is in the Tailwind documentation.
Spacing
The spacing scale counts in quarters of a rem, so 4 is 1rem (16 pixels by default) and 8 is 2rem.
| Class | What it does |
|---|---|
p-4 |
Padding on all sides |
px-4 / py-4 |
Padding left and right / top and bottom |
pt-4, pr-4, pb-4, pl-4 |
Padding on one side |
m-4, mx-auto |
Margin; mx-auto centres a block |
-mt-4 |
A negative margin |
gap-4 |
Space between items in a flex or grid layout |
space-y-4 |
Space between stacked children |
Sizing
| Class | What it does |
|---|---|
w-full / h-full |
100% width / height |
w-1/2 |
Half width |
max-w-prose |
A comfortable reading width |
max-w-screen-lg |
Caps width at the large breakpoint |
min-h-screen |
At least the height of the window |
size-12 |
Width and height together |
Type
| Class | What it does |
|---|---|
text-sm, text-base, text-lg, text-xl … text-6xl |
Font size |
font-normal, font-medium, font-semibold, font-bold |
Weight |
leading-tight, leading-relaxed |
Line height |
tracking-tight, tracking-wide |
Letter spacing |
text-left, text-center, text-right |
Alignment |
uppercase, italic, underline |
Style |
truncate |
Cuts long text with an ellipsis |
Colour
Colours run from 50 (lightest) to 950 (darkest).
| Class | What it does |
|---|---|
text-gray-700 |
Text colour |
bg-blue-600 |
Background colour |
border-gray-200 |
Border colour |
bg-black/50 |
50% opacity |
Layout
| Class | What it does |
|---|---|
flex, inline-flex |
Flexbox |
flex-col |
Stack items vertically |
items-center |
Centre on the cross axis |
justify-between |
Push items to the ends |
flex-wrap |
Let items wrap |
grid grid-cols-3 |
A three-column grid |
col-span-2 |
Span two columns |
hidden, block |
Hide or show |
relative, absolute, sticky top-0 |
Positioning |
Borders and effects
| Class | What it does |
|---|---|
border, border-2 |
Border width |
rounded, rounded-lg, rounded-full |
Rounded corners |
shadow, shadow-lg |
Drop shadow |
opacity-50 |
Transparency |
transition, duration-200 |
Animate changes |
Responsive and state prefixes
Put a prefix before any class to apply it only at a size or in a state.
| Prefix | Applies |
|---|---|
sm: |
From 640px wide |
md: |
From 768px |
lg: |
From 1024px |
xl: |
From 1280px |
2xl: |
From 1536px |
hover: |
When the pointer is over it |
focus: |
When it has keyboard focus |
dark: |
In dark mode |
Example: grid grid-cols-1 md:grid-cols-3 is one column on phones and three from tablets up.
Tailwind without remembering classes
RapidWeaver Elements is a visual Tailwind builder for Mac. Set spacing, colour and layout with controls, and Elements writes these classes for you. You can also type any class onto any component. Its breakpoints match the prefixes above.
Questions about Tailwind classes
What does the number in a Tailwind class mean?
For spacing and sizing it’s a step on the scale, where each step is 0.25rem. For colours it’s the shade, from 50 to 950.
How do I use a value that isn’t on the scale?
Use square brackets: w-[350px] or bg-[#196ee4]. Use it sparingly, or designs drift.