Skip to content

arraypress/google-fonts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@arraypress/google-fonts

Google Fonts loader — 32 curated web fonts with on-demand loading, CSS font-family mappings, and deduplication. No framework dependency.

Installation

npm install @arraypress/google-fonts

Usage

import { getFontFamily, loadFont, needsLoading, getFontList, FONTS } from '@arraypress/google-fonts';

// Get CSS font-family value
getFontFamily('inter'); // '"Inter", sans-serif'
getFontFamily('system'); // ''

// Load a font (injects <link> into <head>, deduplicates)
loadFont('inter');
loadFont('inter'); // no-op, already loaded

// Check if a font needs remote loading
needsLoading('inter'); // true
needsLoading('system'); // false

// Get all fonts for a picker UI
const fonts = getFontList();
// [{ key: 'geist', label: 'Geist', family: '"Geist", sans-serif', category: 'sans-serif' }, ...]

Available Fonts (32)

Key Family Category
system (browser default)
geist Geist sans-serif
serif Playfair Display serif
mono JetBrains Mono monospace
poppins Poppins sans-serif
inter Inter sans-serif
dm-sans DM Sans sans-serif
space-grotesk Space Grotesk sans-serif
outfit Outfit sans-serif
plus-jakarta Plus Jakarta Sans sans-serif
sora Sora sans-serif
cabinet-grotesk Cabinet Grotesk sans-serif
montserrat Montserrat sans-serif
raleway Raleway sans-serif
lato Lato sans-serif
open-sans Open Sans sans-serif
roboto Roboto sans-serif
nunito Nunito sans-serif
work-sans Work Sans sans-serif
rubik Rubik sans-serif
manrope Manrope sans-serif
figtree Figtree sans-serif
onest Onest sans-serif
lexend Lexend sans-serif
urbanist Urbanist sans-serif
quicksand Quicksand sans-serif
archivo Archivo sans-serif
barlow Barlow sans-serif
bricolage-grotesque Bricolage Grotesque sans-serif
instrument-sans Instrument Sans sans-serif
crimson-pro Crimson Pro serif

API

FONTS: Record<string, string>

CSS font-family values for each font key.

GOOGLE_FONT_URLS: Record<string, string>

Google Fonts API family strings for loading.

FONT_KEYS: string[]

All available font keys.

getFontFamily(key: string): string

Get the CSS font-family value for a font key. Returns empty string if not found.

loadFont(key: string): void

Load a Google Font by key. Injects a <link> tag into <head>. Deduplicates. SSR safe.

needsLoading(key: string): boolean

Check if a font key needs remote loading from Google Fonts.

getFontList(): FontInfo[]

Get font metadata for a picker UI. Returns all fonts except system.

License

MIT

About

Google Fonts utilities for font loading and selection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors