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

Scaffolding tools

3m:12s

You can create scaffolding utilities for yourself.

This is very powerful because they make the rest of your utility building experience a lot simpler, but most people don’t see it.

I’ve tried building a lot of different scaffolds and ended up not using many of them.

These are the few that I keep using consistently.

Border Scaffold

It is quite common to reuse the same border with border-style, border-color, and border-radius throughout the entire page, so it makes sense to have a global way to determine these values.

I felt that the best way to determine it is in either @theme or in :root.

:root {
--border-width: 1px;
--border-style: solid;
--border-color: var(--color-neutral-700);
--radius: calc(var(--spacing) * 2);
}

I want to use these values across all of my different utilities, so it makes sense to create a scaffold around them.

@utility border-scaffold {
border: var(--border-width) var(--border-style) var(--border-color);
border-radius: var(--radius);
}

When I create utilities or components, if I need a border scaffold, I can just apply it.

.card {
@apply border-scaffold;
}

Transition Scaffold

There is a similar idea when it comes to transitions. I want the transitions across the site to be kept consistent as much as I can, so I begin by creating transition variables upfront:

:root {
--transition-duration: 200ms;
--transition-delay: 0ms;
--transition-easing: ease-out;
}

Then I create a transition-scaffold to apply these values throughout my codebase. This transition-scaffold includes a basic list of transition properties that I use that don’t cause jank.

@utility transition-scaffold {
--transition-values: var(--transition-duration) var(--transition-delay)
var(--transition-easing);
--transition-props:
background-color, border-color, color, fill, stroke, opacity, outline,
transform, translate, scale, rotate, skew, perspective;
transition: var(--transition-values);
transition-property: var(--transition-props);
}
Note

Yes — this is an alarming number of properties to transition. But writing all of them down is better than a lazy all property that transitions everything.

Then whenever I want to include transitions, I do not have to manually write down the values. I can simply use the transition-scaffold.

If I want to change transition properties, I can simply write a new transition-property value (or append to it, depending on circumstances).

.component {
@apply transition-scaffold;
transition-property: /* Added as necessary */;
}

Extended transition scaffold

I also have a scaffold for more things that I typically do not transition, that includes backdrop-filter, filter, gap, display and overlay.

I only use this when transitioning these properties are necessary.

@utility transition-scaffold-extended {
@apply transition-scaffold;
--transition-props:
backdrop-filter, background, border-color, color, display, fill, filter,
gap, opacity, outline, overlay, stroke, transform, translate, scale, rotate,
skew, perspective;
transition-behavior: allow-discrete;
}

Outline Scaffold

Nowadays, I prefer using outline to highlight the focused element. This is helpful because it’s easier to locate the focused element when there is a consistent visual marker to look for.

So I started by creating outline properties in the :root.

:root {
/* Outline */
--outline-width: 2px;
--outline-style: solid;
--outline-focus-color: oklch(61.52% 0.178 257.59deg);
--outline-offset: 0px;
}

The outline scaffold is a little bit more complex because we only want the outline to show when it is being focused on. So we need to:

  • Set the outline-color to be transparent in the beginning.
  • And only show it when the element is focused
@utility outline-scaffold {
outline: var(--outline-width) var(--outline-style) transparent;
outline-offset: var(--outline-offset);
&:focus-visible {
outline-color: var(--outline-focus-color);
}
}

Focus Within

Sometimes I want elements to contain an outline when items within are being focused. For that, I create a focus-within utility. This is usually on the same element as the interact-within variant.

Here I need to make sure only the parent gets the focus. All the internal items do not have an outline focus.

@utility focus-within {
outline: var(--outline-width) var(--outline-style) transparent;
outline-offset: var(--outline-offset);
&:focus-within {
outline-color: var(--outline-focus-color);
}
* {
--outline-focus-color: transparent;
}
}

That’s it!