AI Workshop: learn to build apps with AI →
Tailwind CSS: How to use custom fonts with Tailwind CSS

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


Assuming you have an app configured to use Tailwind CSS, your main CSS file should include Tailwind and your font import.

When using Google Fonts, the @import for the font must come first, before @import "tailwindcss":

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;700;900&display=swap');
@import "tailwindcss";

Then add a base layer to set the default font:

@layer base {
  html {
    font-family: Inter, system-ui, sans-serif;
  }
}

In the end, your CSS file will look like this:

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;700;900&display=swap');
@import "tailwindcss";

@layer base {
  html {
    font-family: Inter, system-ui, sans-serif;
  }
}

Now your default font is set, and you can use font-bold, font-medium, and similar classes to set various weights.

Lessons in this unit:

0: Introduction
1: Box model properties
2: Colors
3: Typography
4: Flexbox and Grid in Tailwind
5: Modifiers
6: Responsive design in Tailwind
7: Apply a style to children with Tailwind
8: How to fix Unknown at rule @tailwindcss (unknownAtRules) in VS Code
9: How to align center vertically using Tailwind
10: ▶︎ How to use custom fonts with Tailwind CSS
11: Setting up Tailwind CSS on Vite
12: Show-hide an element based on existence of a parent class in Tailwind
13: The Tailwind Cheat Sheet
14: How to set up Tailwind CSS (v4)
15: You can’t generate classes dynamically in Tailwind