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

Dark mode tricks

9m:46s

Shadow-based elevations are useful on light-mode designs, but they look extremely weird in dark-mode.

Shadows look fine on light-mode
But they look wonky in dark-mode

This happens because of a very simple reason.

  • In the day, there is a single light source from the sun. Most light-mode designs are based on this single light source concept.
  • At night, there is no single light source. Instead there are multiple different kinds of light sources. Dark-mode designs can use any of these light sources.

Light sources at night

There are 5 kinds of lights at night:

  • Simple elevation
  • Neon lights
  • Neon lights behind a fixture (also halo lighting)
  • Spotlights
  • Backlit

Simple elevation

Simple elevation is a lightening of the background to simulate objects that are closer to you. This is often described in many framework libraries.

To do this, we can just add a background-color with a light opacity to each card.

<div class="bg-white/3">1</div>
<div class="bg-white/5">2</div>
<div class="bg-white/7">3</div>
<div class="bg-white/9">4</div>
<div class="bg-white/11">5</div>
<div class="bg-white/13">6</div>
<div class="bg-white/15">7</div>

Neon lights

Neon lights give out light by themselves. When you look at these lights, you’ll see a glow that diffuses from the light. This can be done easily with text-shadows or drop-shadow.

When you do this, the x and y of the shadow must be 0 because the neon light is a light source. So we only use blur.

.selector {
text-shadow: 0 0 0.5em var(--color-yellow-500);
}

Neon Light

You can do this in Tailwind, of course. But you’d have to write the entire CSS in their text-shadow-* utility which is not very nice…

<div class="text-shadow-[0_0_0.5em_var(--color-yellow-500)]">...</div>

I’d argue it’s easier to write an inline style in this case, but that’s tedious too — and difficult to use:

<div style="text-shadow: 0 0 0.5em var(--color-yellow-500)">...</div>

To make life a little bit simpler, I created a text-shadow utility. It comes along with functional utilities:

  • tsx-*: x of the text shadow
  • tsy-*: y of the text shadow
  • tsb-*: The shadow’s blur
  • tsc-*: The shadow’s color, defaults to currentcolor

The text shadow declaration from above becomes easier now, because:

  • x and y must be 0, so we can exclude them.
  • We’re going to use currentcolor for the shadow, so we can exclude it too.

Which means, we only need to define the blur.

<div class="text-yellow-500 text-shadow tsb-[0.5em]">Neon Light</div>

If you dislike functional utilities, you can always just use the main utility and adjust the CSS variables directly.

.neon {
@apply text-shadow;
--text-shadow-blur: 0.5em;
}

Neon Light

Halo lighting

Neon lights don’t have to be placed front-and-center. They can be placed behind an object. And that creates a glow behind the object.

Here we can use the same elevation-* utilities to create a soft, rich glow.

<!-- works for elevation-1 to elevation-7 -->
<div class="elevation-4 sy-0 sb-[1px] sc-yellow-500">...</div>

This uses the functional utilities we’ve discussed back in the shadow lesson. But if you dislike functional utilities, you can use the CSS variables directly too.

.halo {
@apply elevation-4;
--shadow-y: 0;
--shadow-blur: 1px;
--shadow-color: var(--color-yellow-500);
}

The thing about dark mode is that any light intensity can work because there is nothing to cover how bright a light source can be. So you can go crazy and magnify the source with blur, spread, or even opacity — within reason, of course.

Here’s an example where I bumped the elevation spread by just 0.25px per layer. Crazy results.

Halo lighting + elevation

You can combine halo lighting with elevation. In this case, it makes sense for:

  • The lighting to be larger when it is closer to the background
  • And the lighting to be smaller when it is farther away from the background

Halo lighting on text

Not all text needs to be neon lights themselves. They can also contain backlighting around or behind the text. We already discussed this effect in text-stroke a few lessons back.

<!-- Tailwind implementation -->
<div class="text-stroke spl-stroke-yellow-500 drop-shadow dsb-[0.5em] dsa-0.75"></div>
/* CSS Implementation */
.effect {
@apply text-stroke;
@apply drop-shadow;
--stroke-color: var(--color-yellow-500);
--drop-shadow-blur: 0.5em;
--drop-shadow-alpha: 0.75;
}

Neon Light

If you’re up for making things a little bit nicer, you could even add other coloured shadows to this implementation as well. Here’s an example where I add orange text-shadow into the mix.

Neon Light

Spotlights

Spotlights can bring focus to some objects by lighting them up.

To create a spotlight effect, we can use linear or radial gradients depending on the angle of the spotlight.

  • A radial gradient looks more real, but it is more complex to create.
  • A linear gradient looks flatter, but it is easier to create.
<!-- Linear gradient -->
<div class="linear-gradient gradient-angle-180 from-purple-300/15 to-white/0 ">
Linear Gradient
</div>
<!-- Radial gradient -->
<div
class="radial-gradient from-purple-300/16 to-white/0"
style="
--gradient-position: 50% 0%;
--gradient-shape: circle;
"
>
Radial Gradient
</div>

They both look like the items are more interesting compared to plain elevation.

Single Colour

Linear Gradient

Radial Gradient

If you want to bring this up a notch, you can imagine that the rim of the item is a reflective material. So when light shines on this rim, you create a brighter gradient compared to the items within the card.

Single Colour

Radial Gradient

Radial Gradient

I’ll show you a simple way to achieve this effect in the next lesson.

Backlit

Backlit simply means that light is showing from behind. We are already used to this because the computer or even a TV creates light in the middle of a dark room.

This is why colors and shapes look all right even if we are using them plainly.

If you put a box with backdrop-filter above backlit elements, you get Glassmorphism — this basically means light is diffused on the box with a blur filter.

<div class="backdrop-blur-[16px]"></div>

You have to be mindful about contrast when doing this!

Of course, we can take it up a notch with some gradients on the glass box as well. A possible effect can look like this:

You have to be mindful about contrast when doing this!