Get Started

Usage

Use Nuxt Fonts with any CSS framework or library.

Pure CSS

You can use Nuxt Fonts with pure CSS by adding font-family declarations to your CSS:

assets/css/fonts.css
div {
  font-family: 'Inter', sans-serif;
}
Note that Nuxt Fonts will only generate CSS for the first font in a font-family declaration. Subsequent fonts in the list will be used to generate metrics for font fallbacks.

Tailwind CSS

v3 and below

You can use Nuxt Fonts with Tailwind CSS by setting fontFamily in your configuration file:

tailwind.config.js
export default {
  theme: {
    extend: {
      fontFamily: {
        custom: ['Inter'],
      },
    },
  },
}
If the font name contains an invalid identifier (like a space character), you'll need to wrap it in quotes or escape the character manually. Read more here.

v4 (experimental)

TailwindCSS v4 brings a brand new way for configuration. In v4 if you want to specify a font, you would use a CSS variable:

main.css
@theme {
  --font-display: "Inter", "sans-serif";
}

As it uses CSS variables, you should enable the Nuxt Fonts processCSSVariables experimental feature to enable support for processing CSS variables for font family names:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxt/fonts'],
  fonts: {
    experimental: {
      processCSSVariables: true,
    },
  }
})
Please note that processCSSVariables is still an experimental feature and may have a performance impact.

UnoCSS

You can use Nuxt Fonts with UnoCSS by setting fontFamily in your configuration file:

uno.config.js
import { defineConfig } from 'unocss'

export default defineConfig({
  theme: {
    fontFamily: {
      inter: 'Inter',
    },
  },
})