Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and use UnoCSS atomic CSS engine with presets like Wind (Tailwind-compatible), Icons, and Attributify.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/preset-web-fonts.md
1---2name: preset-web-fonts3description: Easy Google Fonts and other web fonts integration4---56# Preset Web Fonts78Easily use web fonts from Google Fonts and other providers.910## Installation1112```ts13import { defineConfig, presetWebFonts, presetWind3 } from 'unocss'1415export default defineConfig({16presets: [17presetWind3(),18presetWebFonts({19provider: 'google',20fonts: {21sans: 'Roboto',22mono: 'Fira Code',23},24}),25],26})27```2829## Providers3031- `google` - Google Fonts (default)32- `bunny` - Privacy-friendly alternative33- `fontshare` - Quality fonts by ITF34- `fontsource` - Self-hosted open source fonts35- `coollabs` - Privacy-friendly drop-in replacement36- `none` - Treat as system font3738## Font Configuration3940```ts41fonts: {42// Simple43sans: 'Roboto',4445// Multiple (fallback)46mono: ['Fira Code', 'Fira Mono:400,700'],4748// Detailed49lato: [50{51name: 'Lato',52weights: ['400', '700'],53italic: true,54},55{56name: 'sans-serif',57provider: 'none',58},59],60}61```6263## Usage6465```html66<p class="font-sans">Roboto</p>67<code class="font-mono">Fira Code</code>68```6970## Local Fonts7172Self-host fonts:7374```ts75import { createLocalFontProcessor } from '@unocss/preset-web-fonts/local'7677presetWebFonts({78provider: 'none',79fonts: { sans: 'Roboto' },80processors: createLocalFontProcessor({81cacheDir: 'node_modules/.cache/unocss/fonts',82fontAssetsDir: 'public/assets/fonts',83fontServeBaseUrl: '/assets/fonts',84})85})86```8788<!--89Source references:90- https://unocss.dev/presets/web-fonts91-->92