Skip to content

UnoCSS preset fonts not auto-detected #757

@onmax

Description

@onmax

Problem

Using UnoCSS preset (nimiq-css) that includes font declarations. @nuxt/fonts doesn't detect fonts defined in preset CSS because it only scans user CSS files, not preset internals.

Current Behavior

Root Cause (UPDATED)

CSS Scanning Timing Issue: @nuxt/fonts scans for font-family usage BEFORE UnoCSS transforms utilities (like font-sans) into actual font-family declarations. When fonts are only used via UnoCSS utilities, they're never detected.

Workaround

Use global: true to force font injection:

fonts: {
  families: [
    { name: 'Mulish', provider: 'google', weights: [400, 600, 700], global: true },
    { name: 'Fira Mono', provider: 'google', weights: [400], global: true },
  ],
}

Ideal Solution

@nuxt/fonts should hook into UnoCSS's generated CSS instead of only scanning source files. This would enable auto-detection from:

  • UnoCSS theme.fontFamily configuration
  • Utility class usage (font-sans, font-mono, etc.)
  • Preset font declarations

This requires integration with UnoCSS build pipeline to scan AFTER transformation.

Reference: nimiq-ui repository (commit: 68e96cd)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions