Font Weight

    Usage

    Control the font weight of an element using the utilities.

    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 documentation.

    Font Weight - 图2

    all

    sm

    md

    Font Weight - 图5

    lg

    xl

      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.

      Font Weight - 图7

      1. <div class="text-center text-blue-700">
      2. <a href="#" class="font-normal hover:font-bold">Hover over this link</a>
      3. </div>

      To control the font weight of an element on focus, add the focus: prefix to any existing style and decoration utility. For example, use to apply the font-bold utility on focus.

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

      1. <input class="... md:font-normal md:focus:font-bold ..." value="Focus me">

      Customizing

      By default Tailwind provides 10 font-weight utilities. You change, add, or remove these by editing the theme.fontWeight section of your Tailwind config.

      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:

      1. // tailwind.config.js
      2. module.exports = {
      3. variants: {
      4. + fontWeight: ['responsive', 'hover', 'focus', 'active', 'group-hover'],
      5. }
      6. }

      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:

      1. // tailwind.config.js
      2. module.exports = {
      3. corePlugins: {
      4. // ...
      5. + fontWeight: false,
      6. }