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.

    Font Size - 图2

    all

    Font Size - 图4

    md

    lg

    Font Size - 图6

    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.

      1. // tailwind.config.js
      2. module.exports = {
      3. theme: {
      4. sm: ['14px', '20px'],
      5. base: ['16px', '24px'],
      6. lg: ['20px', '28px'],
      7. xl: ['24px', '32px'],
      8. }
      9. }

      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:

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

      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: