How to create responsive type using Tailwind CSS in a NextJS project

In your tailwind.config file, under the extend property, add font-sizes that use clamped values.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 01/01/2025 at 12:55
Last Updated on 01/01/2025 at 14:03
<p>Two flowers that represent NextJS and Tailwind CSS side by side. Beneath them sits the text "Responsive Type."</p>

In your tailwind.config file, under the extend property, add font-sizes that use clamped values.

Subscribe

This article was made possible by Pelayo Trives Pozuelo.

Please note the following solution only works for dynamic font-sizes and does not yet work for dynamic font-weights or line-heights.

Discover Pelayo Trives Pozuelo

A working example of this tutorial can be found on the archive that exhibits my students work.

Check out the Student Works

Step One: Determine the CSS

<p>A screenshot of the font-size generator website.</p>

Responsive font-sizes are achieved using the clamp css parameter which allows you to scale a font-size between a minimum and maximum value that scales as the view width of a screen changes.

To simplify this calculation Pelayo Trives Pozuelo made us aware of the Clamp Font-Size Generator website which calculates it for you.

Please note that the minimum viewport width and maximum viewport width must be considered as:

  • Don't become smaller below this value (minimum viewport width).
  • Don't become larger after this value (maximum viewport width).
Go to Clamp Font-Size Generator

Step Two: Add to Tailwind Config

<p>A screenshot of the tailwind config showing responsive font-sizes.</p>

Under the extend property of the tailwind.config, create a font-size for each responsive font-size and paste in the value calculated in Step One.

Step Three: Apply

<p>A screenshot that shows how we applied the responsive type to a class within a NextJS component.</p>

In the NextJS project, apply the typographic style as would with any other text style (i.e. text-...).

Step Four: Test

<p>A screenshot of the archive.</p>

Run the project locally and scale the webpage to confirm that the type scales as expected.

For a working example visit  the archive that exhibits my students work.

Check out the Student Works

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe