Font Size
Control the font size of an element using the utilities.
To control the font size of an element at a specific breakpoint, add a {screen}:
prefix to any existing font size utility. For example, use md:text-lg
to apply the text-lg
utility at only medium screen sizes and above.
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
all
md
lg
xl
The quick brown fox jumped over the lazy dog.
You can provide a default line-height for each of your font-sizes using a tuple of the form [fontSize, lineHeight]
in your tailwind.config.js
file.
// tailwind.config.js
module.exports = {
theme: {
sm: ['14px', '20px'],
base: ['16px', '24px'],
lg: ['20px', '28px'],
xl: ['24px', '32px'],
}
}
We don’t do this out-of-the-box for backwards compatibility reasons, but it can be a very convenient customization to make in your own projects.
If you also want to provide a default letter-spacing value for a font size, you can do so using a tuple of the form [fontSize, { letterSpacing, lineHeight }]
in your tailwind.config.js
file.
By default, only responsive variants are generated for text sizing utilities.
You can control which variants are generated for the text sizing utilities by modifying the fontSize
property in the variants
section of your file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- fontSize: ['responsive'],
+ fontSize: ['responsive', 'hover', 'focus'],
}
}
If you don’t plan to use the text sizing utilities in your project, you can disable them entirely by setting the fontSize
property to false
in the corePlugins
section of your config file: