How to add Custom Fonts in a Tailwind CSS Project ?
Last Updated :
05 Feb, 2024
Adding custom fonts to a Tailwind CSS project involves configuring the fontFamily
property within the theme
section of the tailwind.config.js
file. You can then apply the custom font to specific elements using Tailwind utility classes.
Syntax
// tailwind.config.js
module.exports = {
theme: {
extend: {
fontFamily: {
custom: ['CustomFont', 'sans-serif'],
},
},
},
// Other Tailwind configurations...
};
Here the
fontFamily
Property configures custom font families within the theme
section, specifying the font name and fallbacks.
Key Features
- Custom Font Definition: The
fontFamily
property allows you to define and use custom fonts, providing flexibility in typography.
- Easy Application: Once configured, apply the custom font to elements using the
font-custom
utility class in your HTML.
- Global Consistency: By defining custom fonts in the Tailwind configuration, you ensure consistent typography throughout your project.
Share your thoughts in the comments
Please Login to comment...