Before we dive deeper into creating your own font size system, let’s take a look at what Tailwind provides you with. This gives you a good idea why we are not using Tailwind’s built-in system.
Tailwind’s system
Tailwind’s system uses the text-* utility, and it writes both font-size and line-height properties. The original values are as follows:
| Utility | Font Size | Line Height |
|---|---|---|
text-xs |
0.75rem (12px) |
1.33333333 |
text-sm |
0.875rem (14px) |
1.42857143 |
text-base |
1rem (16px) |
1.5 |
text-lg |
1.125rem (18px) |
1.55555556 |
text-xl |
1.25rem (20px) |
1.4 |
text-2xl |
1.5rem (24px) |
1.33333333 |
text-3xl |
1.875rem (30px) |
1.2 |
text-4xl |
2.25rem (36px) |
1.11111111 |
text-5xl |
3rem (48px) |
1 |
text-6xl |
3.75rem (60px) |
1 |
text-7xl |
4.5rem (72px) |
1 |
text-8xl |
6rem (96px) |
1 |
text-9xl |
8rem (128px) |
1 |
The problems with this approach
It doesn’t work with multiple typefaces
You know from the previous lesson that the best line height value depends on the typeface itself. In general:
- A typeface with a larger
x-heightrequires a largerline-height. - And one with a smaller
x-heightrequires a smallerline-height.
The problem with Tailwind’s system is that line-height values are fixed according to the font-size. It does not take into account the typeface that you’re using — which means it is only designed for one typeface.
If you want to have multiple typefaces, or if you want to use a typeface that is not designed for the Tailwind system, you’ve got to change your line-height values anyway. But changing this tightly-coupled system is a pain in the ass… so we will explore a different font-size system in a bit.
You can’t add sizes easily
The second problem is the reliance on t-shirt sizes as keywords.
If you want to create a size between small and medium, you will have a problem, because a size between small and medium generally doesn’t come to mind. This means you have to do a lot of adjustments to it — which, again, is a pain in the ass.
So let’s explore other alternatives that can work better than this one.
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