Skip to content

Fonts

Manage web font loading with a provider abstraction layer.

The fonts plugin handles web font loading through configurable providers. It generates @font-face rules and CSS imports as preflight CSS, with built-in support for Google Fonts and extensible provider architecture.

sh
pnpm add -D @pikacss/plugin-fonts
sh
npm install -D @pikacss/plugin-fonts
sh
yarn add -D @pikacss/plugin-fonts
ts
import { defineEngineConfig } from '@pikacss/core'
import { fonts } from '@pikacss/plugin-fonts'

export default defineEngineConfig({
  plugins: [fonts()],
  fonts: {
    provider: 'google',
    families: [
      { name: 'Inter', weights: [400, 500, 600, 700] },
      { name: 'Fira Code', weights: [400, 500] },
    ],
  },
})

Config

PropertyDescription
providerDefault font provider service. Built-in options: 'google', 'none'.
fontsFont metadata entries describing families to load with weights and variants.
familiesFont family configurations with name, weights, italic variants, and optional per-font provider.
importsRaw CSS @import URLs for font stylesheets to inject.
facesExplicit @font-face rule definitions for self-hosted or custom fonts.
displayfont-display property value for generated @font-face rules. Default: 'swap'.
providersCustom font provider definitions created with defineFontsProvider().
providerOptionsPer-provider configuration options passed to the provider resolver.

See API Reference — Plugin Fonts for full type signatures and defaults.

Next