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

Tailwind's gradient system

2m:38s

Tailwind has a gradient utility that is often celebrated as well. It is quite intuitive, but I don’t like it.

Linear gradients

To create a linear gradient, you need these utilities:

  • a bg-linear gradient utility
  • a direction (or angle)
  • a start colour stop
  • an end colour stop

It sounds complicated, but these 4 values can come together like this:

<div class="bg-linear-to-r from-blue-500 to-purple-500"></div>
  • bg-linear- is the linear gradient utility
  • to-r is the direction (to right)
  • from-blue-500 is the starting colour
  • to-purple-500 is the ending colour

Gradients can have an angle

Tailwind gives you 8 shortcuts for gradient directions (the 8 cardinal points).

Direction Utility
Right bg-linear-to-r
Left bg-linear-to-l
Bottom bg-linear-to-b
Top bg-linear-to-t
Bottom right bg-linear-to-br
Bottom left bg-linear-to-bl
Top right bg-linear-to-tr
Top left bg-linear-to-tl

I don’t normally like to use these angles because they’re expected, so they feel rigid and dull. I tend to use 120deg as my angle for gradients. It feels slightly more dynamic than the values above.

<div class="bg-linear-120 from-blue-500 to-purple-500"></div>
Gradients at 120deg feel a little bit more dynamic

A linear gradient needs two things: a direction and at least two colour stops.

Fade-in gradients

Gradients can start from any opacity — just use the color/opacity syntax.

<div class="bg-linear-120 from-blue-500/20 to-purple-500"></div>

Radial and Conic gradients

Radial and conic gradients have similar syntax — you use bg-radial and bg-conic to create them.

<div class="bg-radial from-blue-500 to-purple-900"></div>
<div class="bg-conic from-blue-500 to-purple-500"></div>

Tailwind lets you adjust radial gradients, but the syntax leaves more to be desired — because you kind of need to remember the exact gradient syntax from CSS to adjust its position and shape.

<div class="bg-radial-[circle_at_25%_75%] from-blue-500 to-purple-900"></div>

Colour stops

Tailwind provides you with 3 colour stops by default.

  • from-*: First colour, at 0%
  • via-*: Second colour, at 50% (optional)
  • to-*: Third colour, at 100%

You can adjust the positional value of any of these stops with additional from, via and to values. This takes a number from 0 to 100 as the percentage value.

  • from-0: Starts at 0%
  • via-30: Second colour at 30%
  • to-90: Third colour at 90%

This means a complex gradient with colours and stops combined can use 7 utilities. (Gasp).

<div
class="bg-linear-to-r
from-0 from-blue-500
via-30 via-purple-500
to-90 to-pink-500
"
></div>

I think there’s a better way to handle gradients — more CSS-like yet more flexible and forgiving. I’ll show you in the next lesson.