Essential CSS
JavaScript Roadmap
Learn JavaScript
Mastering Web Typography
Practical Astro
Understanding Async JS
Unorthodox Tailwind
API Masterclass
Build and Deploy
The Beginner Freelancer
Real World Node
Profile Billing Logout
Unorthodox Tailwind
Lesson Plan
  1. Introduction
    1. Introduction
    2. What Tailwind brings to the table
    3. Tailwind: The Good and The Bad
    4. The First and Most Important Step
    5. Simple Unorthodox System
    6. The System I Use
  2. Tailwind Fundamentals
    1. Introduction
    2. Installing Tailwind
    3. Using Tailwind utilities
    4. Understanding Tailwind’s utility system
    5. Understanding Tailwind values
    6. Understanding Tailwind variants
  3. Unorthodox Fundamentals
    1. Introduction
    2. Making Simple Tailwind Utilities
    3. Components vs Utilities
    4. Specificity, Cascade, and CSS Layers
    5. Debugging Tailwind Styles
    6. Composable Utility System
    7. Create lots of components
  4. Layouts System
    1. Tailwind is great for layouts
    2. Four Types of Layouts
    3. Building Shell Layouts
    4. Building Macro Layouts
    5. Better Responsive Variants
    6. A collection of maximum widths
    7. A note on grid wrappers
    8. Working with sections
    9. Building Micro Layouts
    10. Positioning Layouts
  5. Typography System
    1. Introduction
    2. A system for using multiple typefaces
    3. Tailwind's font-size system
    4. Finding your font-size system
    5. My font-size system
    6. A simple responsive typography system
    7. The main body
    8. Vertical rhythm
  6. Theming System
    1. Introduction
    2. Tailwind's colour system
    3. The pigment system
    4. Tailwind's gradient system
    5. A friendlier gradient system
    6. Handling SVG fill and stroke
    7. Improving Tailwind's colour palette
    8. A simple way to theme
  7. Useful Tools
    1. Introduction
    2. Making functional utilities
    3. Custom variants
    4. Scaffolding tools
    5. Extending Tailwind
  8. Effects System
    1. Introduction
    2. Vertical text
    3. Strikethrough text
    4. Text stroke
    5. Highlighting text
    6. Nicer shadows
    7. Transitioning shadows
    8. Drop shadows
    9. Dark mode tricks
    10. Gradient borders
    11. More effects to explore
  9. Putting Everything Together
    1. The Unorthodox Tailwind process
    2. The 4 systems combined
    3. Create components liberally
    4. Advanced tips
    5. My CSS Structure
    6. A Cheatsheet
    7. Consolidating your thoughts
    8. Parting words

Installing Tailwind

1m:43s

Tailwind requires PostCSS or Vite in your toolchain, so the easiest way to use Tailwind is through a framework like Astro.

You don’t have to worry much about the dev-tooling process nowadays. Most frameworks are quite intuitive here. So grab the framework, use a minimal starter template, and you’re ready to go.

I like to use Astro and I recommend it because:

  1. It is really easy for beginners to pick up.
  2. It is very friendly when it comes to HTML, CSS, and JavaScript basics.
  3. It lets you use any frontend framework, so there’s flexibility and less vendor lock-in.

The downside is Astro introduces a few styling issues, but I argue it’s a lot less headache when compared to certain frameworks like React.

Installing Tailwind in Astro

Follow this guide to install Tailwind in Astro. It’s a pretty straightforward process so you will likely not run into problems here.

Importing Tailwind

A quick gotcha here.

The easiest way to import Tailwind into your projects is through importing the library:

/* This is the gotcha */
@import 'tailwindcss';

If you import this, you’ll likely be taken aback quickly — because Tailwind has aggressive preflight styles (basically, their CSS reset and base styles) that completely change what you would normally expect form a standard CSS Reset file like yours’ truly.

So I omit Tailwind’s preflight styles.

You can do so by importing Tailwind’s base and utilities manually.

/* Start Tailwind CSS without preflight */
@layer theme, base, components, utilities;
@import 'tailwindcss/theme.css' layer(theme);
@import 'tailwindcss/utilities.css' layer(utilities);

Now you’re ready to begin using Tailwind.

One more thing before we move on

I tend to include a reset layer before the base layer so I can include my own resets. This is optional. It’s perfectly fine to include resets in theme or base.

@layer reset, theme, base, components, utilities;
Note

You can see that Tailwind uses CSS Cascade Layers in the quick example above. This is really handy — you’ll learn more in the Unorthodox Fundamentals chapter.