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

Better Responsive Variants

3m:41s

We’ve talked a lot about responsive variants in this course so far, and I would just like to dive a bit deeper into them so it becomes easier for you to build responsive websites.

The trick here is to include custom responsive variants. They should have these qualities:

  1. They make it easy for you to know what’s going on
  2. They are consistent across any website you build.

Tailwind’s built-in variants are insufficient

Tailwind comes with these built-in responsive variants.

Variant Width CSS
sm 640px @media (width >= 40rem) { … }
md 768px @media (width >= 48rem) { … }
lg 1024px @media (width >= 64rem) { … }
xl 1280px @media (width >= 80rem) { … }
2xl 1536px @media (width >= 96rem) { … }

They are insufficient because each of these variants is tied to a device.

In web development, it is a good practice to not use device breakpoints but to use content-based breakpoints. When the content starts to look ugly, you will change your breakpoints.

Better media breakpoint variants

So instead of relying on Tailwind’s built-in variants, I created a set of breakpoint variants across all of my projects.

And there’s a very simple rule here:

  • Every 1 unit is 100px
  • And every half a unit is 50px

I made variants from 100px all the way up to 2000px to cover any device that I may need.

Variant Width CSS
bp1 100px @media (width >= 100px) { … }
bp1.5 150px @media (width >= 150px) { … }
bp2 200px @media (width >= 200px) { … }
... ... ...
bp20 2000px @media (width >= 2000px) { … }

This lets me output any breakpoint at will:

<div class="bp8:p-4">...</div>

And the above simply says: “At the 800px breakpoint, use p-4 utility”.

With this system, I no longer need to remember what md or lg refers to.

Better container breakpoint variants

Besides media queries, Tailwind lets you use container queries as well.

To use it, you add @container to the parent element, then use their container variants to create container queries.

Here’s an example:

<div class="@container">
<div class="@md:p-4">...</div>
</div>

This means: “At @md variant, use p-4 utility”.

But here’s the problem: md represents different numbers in Tailwind’s media query and the container variants. I don’t know why they do this because it’s really confusing.

Here’s a table that shows the difference:

Variant Media query Container query
@3xs — 256px
@2xs — 288px
@xs — 320px
sm / @sm 640px 384px
md / @md 768px 448px
lg / @lg 1024px 512px
xl / @xl 1280px 576px
2xl / @2xl 1536px 672px
@3xl — 768px
@4xl — 896px
@5xl — 1024px
@6xl — 1152px
@7xl — 1280px

Anyway, I applied the same rules for my breakpoint variants onto container variants so you can enjoy it as well:

Variant Width CSS
@bp1 100px @container (width >= 100px) { … }
@bp1.5 150px @container (width >= 150px) { … }
@bp2 200px @container (width >= 200px) { … }
... ... ...
@bp20 2000px @container (width >= 2000px) { … }

With my system, @bp8: means @container (width >= 800px) { … }. I think that’s way easier to remember and use compared to Tailwind’s default values.

Using these via Splendid Layouts

These breakpoint values are added by default to Splendid Layouts so when you use Splendid Layouts, you automatically have them. There is no need to configure anything else.