Font Weight
Utilities for controlling the font weight of an element.
Usage
Control the font weight of an element using the .font-{weight}
utilities.
.font-hairline
The quick brown fox jumped over the lazy dog.
.font-thin
The quick brown fox jumped over the lazy dog.
.font-light
The quick brown fox jumped over the lazy dog.
.font-normal
The quick brown fox jumped over the lazy dog.
.font-medium
The quick brown fox jumped over the lazy dog.
.font-semibold
The quick brown fox jumped over the lazy dog.
.font-bold
The quick brown fox jumped over the lazy dog.
.font-extrabold
The quick brown fox jumped over the lazy dog.
.font-black
The quick brown fox jumped over the lazy dog.
<p class="font-hairline ...">The quick brown fox ...</p>
<p class="font-thin ...">The quick brown fox ...</p>
<p class="font-light ...">The quick brown fox ...</p>
<p class="font-normal ...">The quick brown fox ...</p>
<p class="font-medium ...">The quick brown fox ...</p>
<p class="font-semibold ...">The quick brown fox ...</p>
<p class="font-bold ...">The quick brown fox ...</p>
<p class="font-extrabold ...">The quick brown fox ...</p>
<p class="font-black ...">The quick brown fox ...</p>
Responsive
To control the font weight of an element at a specific breakpoint, add a {screen}:
prefix to any existing font weight utility. For example, use md:font-bold
to apply the font-bold
utility at only medium screen sizes and above.
For more information about Tailwind's responsive design features, check out the Responsive Design documentation.
<p class="font-normal sm:font-bold md:font-thin lg:font-semibold xl:font-black ...">The quick brown fox jumped over the lazy dog.</p>
The quick brown fox jumped over the lazy dog.
Hover
To control the font weight of an element on hover, add the hover:
prefix to any existing style and decoration utility. For example, use hover:font-bold
to apply the font-bold
utility on hover.
<div class="text-center text-blue-700">
<a href="#" class="font-normal hover:font-bold">Hover over this link</a>
</div>
Hover utilities can also be combined with responsive utilities by adding the responsive {screen}:
prefix before the hover:
prefix.
<a href="#" class="... md:font-normal md:hover:font-bold ...">Link</a>
Focus
To control the font weight of an element on focus, add the focus:
prefix to any existing style and decoration utility. For example, use focus:font-bold
to apply the font-bold
utility on focus.
<input class="font-normal focus:font-bold ..." value="Focus me">
Focus utilities can also be combined with responsive utilities by adding the responsive {screen}:
prefix before the focus:
prefix.
<input class="... md:font-normal md:focus:font-bold ..." value="Focus me">
Customizing
Font Weights
By default Tailwind provides 10 font-weight
utilities. You change, add, or remove these by editing the theme.fontWeight
section of your Tailwind config.
// tailwind.config.js
module.exports = {
theme: {
fontWeight: {
- hairline: 100,
+ 'extra-light': 100,
- thin: 200,
light: 300,
normal: 400,
medium: 500,
- semibold: 600,
bold: 700,
- extrabold: 800,
+ 'extra-bold': 800,
black: 900,
}
}
}
Responsive and pseudo-class variants
By default, only responsive, hover and focus variants are generated for font weight utilities.
You can control which variants are generated for the font weight utilities by modifying the fontWeight
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate active and group-hover variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- fontWeight: ['responsive', 'hover', 'focus'],
+ fontWeight: ['responsive', 'hover', 'focus', 'active', 'group-hover'],
}
}
Disabling
If you don't plan to use the font weight utilities in your project, you can disable them entirely by setting the fontWeight
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ fontWeight: false,
}
}