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.)
Three different fonts used on the same line.
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.
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson