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

A system for using multiple typefaces

3m:41s

If you do some quick research online, almost everyone will tell you to use 1-2 typefaces for your design, but there are designers like Bethany Heck who use 4-5 typefaces.

When I first heard this, I was extremely shocked. How is that possible?

Over the next few years, I gradually learned to incorporate multiple typefaces into my own designs — and I like it.

The system I’m going to show you is one that helps you use any number of typefaces in your project, easily and quickly, without getting yourself stuck in complexity.

Define your typefaces

The first step is to define your typefaces using the --font namespace in Tailwind.

Most people would tell you to use semantic names for your typefaces at this point, like header, body, and code.

@theme {
--font-header: 'Expose', sans-serif;
--font-body: 'Switzer', sans-serif;
--font-code: 'JetBrains Mono', sans-serif;
}

I don’t like these semantic names because they tie the font down into very specific areas, which prevents you from having the freedom to explore.

Instead, what I like to do is to use the name of the typeface as the variable. It’s easier for me to remember, and it is flexible enough that I can use them anywhere.

@theme {
--font-expose: 'Expose', sans-serif;
--font-switzer: 'Switzer', sans-serif;
--font-jetbrains: 'JetBrains Mono', sans-serif;
}

One utility for each typeface

I like to create one utility for each typeface because it lets me add the base values of what I would like to use for the typeface.

@utility switzer {
@apply font-switzer;
/* css properties here ... */
}

For example, I can set the line-height of the switzer font to 1.6. This is important because the best line-height value is determined by the typeface itself.

Variations of the typeface

You can create variations of each typeface easily once you have the base typeface utility. Here’s an example where I created an uppercase version of switzer.

@utility switzer-upper {
@apply switzer;
font-weight: 550;
text-transform: uppercase;
letter-spacing: 0.03em;
/* Other properties */
}

Note on variable fonts

If you are using variable fonts, it is useful to use font-variation-settings with CSS variables to adjust your font properties. This makes it easy to create variations on top of your settings. (This pattern is very useful.)

Here’s an example where I used --optical-size to change the optical size (opsz) of the font.

/* example with marvin visions font */
@utility marvin {
@apply font-marvin;
line-height: 1;
font-weight: 100;
font-variation-settings: 'opsz' var(--optical-size, 85);
}

This makes it very easy for me to create another variation with a different optical size.

@utility marvin-alt {
@apply marvin;
--optical-size: 50;
}

Adobe variable fonts

At the time of writing, Adobe has a weird issue with their variable fonts where they don’t recognize the font-weight property.

I hope it’s fixed by the time you read this… but if it’s not fixed yet, the best way to circumvent this is to use the custom properties pattern mentioned above.

/* changing font-weight with --font-weight */
@utility stinger {
@apply font-stinger;
font-variation-settings:
'wght' var(--font-weight, 350),
'wdth' var(--font-width, 100);
}

Bonus Tip: Match the x-height

If you want to use typefaces together in very close proximity, it is a good idea to match the x-height of the typefaces that you are going to use. That’s because fonts with different x-height look weird when they are placed very close to each other — especially if they are placed inline.

The easy fix here is to adjust the font-size by a multiple until you see the fonts have the same x-height.

@utility second-font {
font-size: 0.95em;
}

Just to illustrate this, here’s an example where I use three different fonts on the same line. (You probably won’t do this normally, but this gives you a good idea of what this technique can do.)

Before

Three different fonts used on the same line.

After

Three different fonts used on the same line.

The one on the after column looks a lot smoother than the one on the before column.

That’s it! Now you can begin to use multiple fonts on the same design.