Does anybody know any existing plugin for Tailwind CSS which makes font sizes responsive, except for lower and upper screen size where font size is fixed? Similar to the CSS:
body { font-size: calc(16px + (26 - 16) * ((100vw - 768px) / (1280 - 768))); }
@media screen and (max-width: 768px) { body { font-size: 16px; }}
@media screen and (min-width: 1280px) { body { font-size: 26px; }}
1- Define font sizes for each breakpoint on tailwind.config.js
module.exports = {
theme: {
extend: {
fontSize: {
'body-lg': '1rem',
'body': '.875rem',
}
}
}
}
2- Create classes on global.css by importing definitions from config file.
@layer base {
body {
@apply text-body;
}
@screen lg { /* applying font size for lg breakpoint */
body {
@apply text-body-lg;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With