Scale fontsize different viewports #4422
Replies: 2 comments
-
For Tailwind you'll need to make a mental shift. You don't have a single font style that changes value responsively. Instead, you have two font styles and apply them at different breakpoints. The method for that is responsive prefixes. There's an example at https://tailwindcss.com/docs/font-size#responsive The two sizes your hero uses, 48px and 72px, are included in Tailwinds default configuration as You can use the paradigm where you provide just a single class and handle the responsive sizing in the config file if you use the https://github.com/tailwindlabs/tailwindcss-typography plugin. But that's aimed more at styling markup which you don't have control over and so can't add text classes to. The responsive prefixes is the "Tailwindy" way. |
Beta Was this translation helpful? Give feedback.
-
thanks, i will make the mental shift but except for typography this seems lot's of work to me. Within Sass i created a mixin which works great, instead of going for Heading based sizes i use names which works great, also to brief from designer to developer. Since h1 is just semantic, and could inherit any class- i rather use names like hero or title
So for example using
Uses an expressive typeface, can be upscaled 25% with space modifers, is bold, has a lineheight all applied with RFS. I guess i should create a tailwind plugin for this ;-) |
Beta Was this translation helpful? Give feedback.
-
Hi, i'm very new to tailwind.
How would i resize my
hero fontsize at small viewports to (let's say) 48px
Beta Was this translation helpful? Give feedback.
All reactions