Horje
How to add Custom Fonts in a Tailwind CSS Project ?

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.



Reffered: https://www.geeksforgeeks.org


Tailwind CSS

Related
How to add a Background Image using Tailwind CSS ? How to add a Background Image using Tailwind CSS ?
How to implement the Order Utility in Tailwind CSS ? How to implement the Order Utility in Tailwind CSS ?
How to use Flexbox Utilities in Tailwind CSS ? How to use Flexbox Utilities in Tailwind CSS ?
How to change the Font Size and Color of Text in Tailwind CSS ? How to change the Font Size and Color of Text in Tailwind CSS ?
How to set the Width and Height in Tailwind CSS ? How to set the Width and Height in Tailwind CSS ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13