Tailwind Font Family

The Tailwind font family utility class allows you to easily specify the font family for text elements. With Tailwind's font family classes, you can quickly apply different font families to your text without writing custom CSS.

Applying Tailwind Font Family

To apply a tailwind font family to an element, you can use the font-{family} utility class, where {family} represents the desired font family. Tailwind CSS provides a set of default font families that you can use out of the box.

html
<div class=" font-sans....">
This text has the sans-serif font family.
</div>

Preview

This text has the sans-serif font family.
---

In the above example, the font-sans class is applied to the <div> element, setting its font family to a sans-serif font.

Serif

html
<div class=" font-serif...">
This text has the serif font family.
</div>

Preview

This text has the serif font family.
---

Default Tailwind Font Families

Tailwind CSS includes a set of default font families that you can use. Some of the commonly used ones include:

  • font-sans: Sets the font family to a sans-serif typeface.

  • font-serif: Sets the font family to a serif typeface.

  • font-mono: Sets the font family to a monospaced typeface.

You can choose the font family that best suits your design and apply the corresponding utility class to your elements.

Custom Tailwind Font Family

Tailwind CSS also allows you to define your own custom font families in the configuration file. Once defined, you can use your custom font families with the font-{family}utility class. Here's an example of using a custom font family:

html
<div class="font-custom">
This text has a custom font family.
</div>

In the above example, a custom font family called custom is defined in the Tailwind CSS configuration file. The font-custom class is applied to the <div> element, setting its font family to the defined custom font family.

Responsive Tailwind Font Family

Tailwind CSS allows you to apply font families responsively at different breakpoints. To use responsive tailwind font family classes, you can append the breakpoint prefix to the font family class. For example, md:font-serif applies the serif font family starting from the medium breakpoint and above.

html
<div class="font-sans md:font-serif">
This text uses the sans-serif font family by default, but switches to serif starting from the
medium breakpoint.
</div>

In the above example, the font-sans class is applied by default, setting the font family to a sans-serif typeface. However, starting from the medium breakpoint and above (md:font-serif), the font family changes to a serif typeface.

Tailwind Font Family Class Table

ClassProperties
font-sansfont-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
"Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-seriffont-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
font-monofont-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

Windframe Tailwind blocks

Landing page

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner