Description
This plugin generates classes for responsive typography sets. The idea being that instead of giving text styles with multiple Tailwind classes and manually overriding at different breakpoints - you would instead have a responsive system set up.
Similiar to responsive spacing, at AREA 17 we like responsive typesets classes so that the type across a site can be known and predictable. We define our type system and then use them consistently across a site. We never have a unique type style or a unique style at a breakpoint - everything is part of the system.
New in v3.9.0
-
overriding type styles.
Setup
Settable type properties
You can set any CSS key/value type for fonts/text styles and also two some special, none standard font properties you can set:
-
bold-weight
- sets a variable of--bold-weight
and sets anyb
orstrong
children of the element to usefont-weight: var(--bold-weight);
to give you control over the font weights -
font-smoothing
-true
orfalse
, equivalent to Tailwind'santialiased
andsubpixel-antialiased
classes
Output
Based on the reference config mentioned in this guide, for the typeset named
h1
we'd get the following in our CSS:
Similarly for the typeset named h1
we would get classes for
each of the other typesets - in this guide that would include
f-h2
, f-body
etc.
Demo
Based on the reference config mentioned in this guide, we would get the following in our CSS:
f-h1 The quick brown fox jumps over the lazy dog
f-h2 The quick brown fox jumps over the lazy dog
f-body The quick brown fox jumps over the lazy dog
Overriding type styles
Introduced in v3.9.0
.
AREA 17 have been using responsive typography classes for a number of years on every build we have done, where the number 1 rule has always been "if its a type style, its that type style at all breakpoints". That is, if its our responsive "h1" class, then its the responsive "h1" class at all breakpoints. This rule was initially frustrating but has become the accepted norm at AREA 17. But, it is occasionally still a frustration - usually when it comes to product listing or article listing designs.
v3.9.0
brings the ability to override type styles at different
breakpoints. For example, the following example displays as a
f-h4
on smaller screens and as f-code
at larger
screens:
f-h4 lg:f-code The quick brown fox jumps over the lazy dog
Overriding caveat - only versions before v4.0.3
Note: this caveat was fixed in v4.0.3
.
This typography plugin sets common typography values to
initial
:
Only these settings will be overridden when using responsive override classes.
It is possible to set other font type attributes such as
font-size-adjust
when setting up your typography classes:
These more unusual font settings will not be overridden and so you will have to handle these separately.