Responsive font sizes
See original GitHub issueComing from Bootstrap I’m wondering if there is also on Tailwind something like: https://getbootstrap.com/docs/4.5/content/typography/#responsive-font-sizes: Responsive font sizes?
I have
h1 {
@apply text-6xl;
}
but this is good for desktop only.
In mobile I’ll be fine with text-2xl
.
Is there a way to do it without using @screen ... {}
?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How To Create a Responsive Text - W3Schools
Responsive Font Size. The text size can be set with a vw unit, which means the "viewport width". That way the text size...
Read more >The Beginner's Guide to Responsive Text on the Web
font -size to · 1.6vw. On a browser 1000 pixels wide, the text will be a nice and readable 16 pixels large. However,...
Read more >Responsive font size in CSS - Stack Overflow
Use dimensions in % or em. Just change the base font size, and everything will change. Unlike the previous one, you could just...
Read more >Responsive Font Size (Optimal Text at Every Breakpoint)
Fluid font sizes per breakpoint ; 320px (eg: iPhone 4 & 5), 16px ; 768px (eg: iPad portrait), 18px ; 1024px (eg: iPad...
Read more >Font Size Guidelines for Responsive Websites - Editor X
Body text - Font sizes should be around 16px to 18px for legibility (or 1.6rem to 1.8rem using our sizing rules mentioned above)....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @frederikhors,
You can also use RFS (Bootstraps resizing engine) as a PostCSS plugin. Therefor you’ll need to install rfs (
npm install rfs
oryarn add rfs
) and adjust yourpostcss.config.js
file:Now you can use the
rfs()
function, just wrap it around any unit you want to resize in your custom CSS.If you want to use tailwinds
@apply
functionality, you’ll need to enable rfs in yourtailwind.config.js
:If you now use
The following CSS will be generated:
You could also use it for fluid margin or padding utilities if you want to:
Hopes this helps, let me know if anything is still unclear.
Thanks for providing that example @MartijnCuppens!
@frederikhors this is the very first time this has come up so likely not going to dedicate a docs page to it, but we have plans to add a new “guides” section to the docs site in the future where we can publish short articles teaching people how to do stuff like this, and I think this would be a great candidate for that section. I’ve made a note of it!