Typography

Font Weight

Utilities for controlling the font weight of an element.

Quick reference

Class
Properties
font-thinfont-weight: 100;
font-extralightfont-weight: 200;
font-lightfont-weight: 300;
font-normalfont-weight: 400;
font-mediumfont-weight: 500;
font-semiboldfont-weight: 600;
font-boldfont-weight: 700;
font-extraboldfont-weight: 800;
font-blackfont-weight: 900;

Basic usage

Setting the font weight

Control the font weight of an element using the font-{weight} utilities.

Font Weight - 图1

  1. <p class="font-light ...">The quick brown fox ...</p>
  2. <p class="font-normal ...">The quick brown fox ...</p>
  3. <p class="font-medium ...">The quick brown fox ...</p>
  4. <p class="font-semibold ...">The quick brown fox ...</p>
  5. <p class="font-bold ...">The quick brown fox ...</p>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:font-bold to only apply the font-bold utility on hover.

  1. <p class="font-normal hover:font-bold">
  2. <!-- ... -->
  3. </p>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:font-bold to apply the font-bold utility at only medium screen sizes and above.

  1. <p class="font-normal md:font-bold">
  2. <!-- ... -->
  3. </p>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.


Using custom values

Customizing your theme

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

  1. 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, } }}

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off font-weight value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

  1. <p class="font-[1100]">
  2. <!-- ... -->
  3. </p>

Learn more about arbitrary value support in the arbitrary values documentation.