Font Weight
@include('_partials.class-table', [ 'rows' => [ [ '.font-hairline', 'font-weight: 100;', 'Set the font weight of an element to hairline.', ], [ '.font-thin', 'font-weight: 200;', 'Set the font weight of an element to thin.', ], [ '.font-light', 'font-weight: 300;', 'Set the font weight of an element to light.', ], [ '.font-normal', 'font-weight: 400;', 'Set the font weight of an element to normal.', ], [ '.font-medium', 'font-weight: 500;', 'Set the font weight of an element to medium.', ], [ '.font-semibold', 'font-weight: 600;', 'Set the font weight of an element to semibold.', ], [ '.font-bold', 'font-weight: 700;', 'Set the font weight of an element to bold.', ], [ '.font-extrabold', 'font-weight: 800;', 'Set the font weight of an element to extrabold.', ], [ '.font-black', 'font-weight: 900;', 'Set the font weight of an element to black.', ], ] ])
Usage
Control the font weight of an element using the .font-{weight}
utilities.
@component('_partials.code-sample', ['class' => 'font-sans'])
.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.
The quick brown fox ...
The quick brown fox ...
The quick brown fox ...
The quick brown fox ...
The quick brown fox ...
The quick brown fox ...
The quick brown fox ...
The quick brown fox ...
The quick brown fox ...
@endslot @endcomponentResponsive
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.
@component('_partials.responsive-code-sample', ['class' => 'font-sans']) @slot('none')
The quick brown fox jumped over the lazy dog.
@endslot @slot('sm')The quick brown fox jumped over the lazy dog.
@endslot @slot('md')The quick brown fox jumped over the lazy dog.
@endslot @slot('lg')The quick brown fox jumped over the lazy dog.
@endslot @slot('xl')The quick brown fox jumped over the lazy dog.
@endslot @slot('code')The quick brown fox jumped over the lazy dog.
@endslot @endcomponentHover
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.
@component('_partials.code-sample')
@endcomponentHover utilities can also be combined with responsive utilities by adding the responsive {screen}:
prefix before the hover:
prefix.
<a href="#" className="... 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.
@component('_partials.code-sample', ['lang' => 'html'])
@slot('code')
@endslot @endcomponentFocus utilities can also be combined with responsive utilities by adding the responsive {screen}:
prefix before the focus:
prefix.
<input className="... 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.
@component('_partials.customized-config', ['key' => '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, @endcomponent
@include('_partials.variants-and-disabling', [ 'utility' => [ 'name' => 'font weight', 'property' => 'fontWeight', ], 'variants' => [ 'responsive', 'hover', 'focus', ], ])