Videos
Check out our tutorial video series.
Tailwind CSS is a powerful frontend framework. Customize your tailwind theme using GoogleFonts and CSS variable syntax.
This post will show you how to add custom Google Fonts like Inter and Roboto to your Tailwind JS project and extend the default config. Using the methods shown will let you use default tailwind font classes like and
and apply custom Google fonts without the need to import fonts directly.
Go to Google Fonts and pick a few fonts you wish to add to your Tailwind site.
Once you have found some load your project and get ready to add the fonts.
For our example we will use the NextJS google font package to import our custom fonts:
You can install this package using . If you are not using NextJS simply import the fonts directly into your HTML using link tags.
Then we create JS variables for each subset of font we want to use and assign it a CSS variable.
Do the same for other fonts:
Now inject the css variables into your application. For a Next JS project we can add a tag to our
entrypoint file.
The last step is to wire the variables into the so that default font classes apply our selected fonts:
You can now apply the custom fonts using the Tailwind font classes such as :
We can even apply different fonts based on print or screen media. For more examples see the blog.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.