@unitools/font-plugin
This document provides a comprehensive guide on configuring font families using a custom Tailwind CSS plugin. This configuration is tailored for Expo and Next.js applications, enabling seamless font usage across both frameworks.
Installation
To install the package, run the following command:
Usage
Expo
You can use the fonts in your Expo app without plugin configuration. You can use the fonts directly in your code.
Next.js
You can use the fonts in your Next.js app with the plugin configuration. You can use the fonts directly in your code.
You can use like below in your code,
Plugin working
We assume that you have loaded fonts using CSS variables that correspond to the font family names because the fontFamily
property will be split into font-family
and font-weight
.
Explanation
In your Tailwind CSS configuration, you might define a font family like this:
For this to work correctly in a Next.js
application, you need to load the font using a CSS variable that matches the font family name. This means defining a CSS variable in your stylesheet that corresponds to the Inter_500Bold font family. For example:
By doing this, the plugin can map the font family to the corresponding CSS variable and correctly generate the necessary CSS classes. The Tailwind CSS plugin will then create a class like:
Refer to the diagram below to understand the plugin’s functionality in detail: