Typography in Nubisco is built on three layers: a raw scale of discrete sizes, a set of semantic tokens for weight, line height and letter spacing, and type sets: named roles like body-md or heading-compact that bundle size, weight, line height, tracking and family. Components always use type sets, never raw scale values, and a test holds the library to that.
Typefaces
Nubisco declares two typefaces as its defaults: IBM Plex Sans for all UI text and IBM Plex Mono for code. These are the values of --nb-font-family-sans and --nb-font-family-mono. They are not bundled or loaded automatically: until you load them (or override the two variables), text falls back to the system stack. See Loading the fonts below.
IBM Plex Sans
The typeface for all UI text: labels, body copy, headings and display. Plex Sans was drawn for interfaces. It holds its counters open at 12 and 14px, where a product spends most of its life, its figures can be set tabular, and its weights run from a light that suits large numbers to a semibold that carries a small heading.
IBM Plex Mono
Used for code, JSON viewers, technical values, keys and keyboard shortcuts. It is metrically tuned to Plex Sans, so code inside a sentence sits on the same line without a jump.
Loading the fonts
NubiscoUI references --nb-font-family-sans and --nb-font-family-mono everywhere, but it does not ship or auto-load any font files. This keeps the bundle free of fonts you may not want: a consumer that already serves its own typefaces pays nothing. There are two ways to get real fonts on the page.
Option A: override the family variables (bring your own)
If your app already loads fonts (its own @font-face, a bundler plugin, an @fontsource/* package), point the two variables at them on :root. You load the files, NubiscoUI uses them.
/* main.css or App.vue <style>: load Inter and JetBrains Mono yourself, then: */
:root {
--nb-font-family-sans: 'Inter', system-ui, sans-serif;
--nb-font-family-mono: 'JetBrains Mono', ui-monospace, monospace;
}Every type set resolves its family through these two variables, so every role re-points the moment they change. Load at least 300, 400 and 600 of the sans: those are the only weights the library uses.
Option B: the fonts plugin
NubiscoUI exports a Vite plugin that self-hosts IBM Plex Sans and IBM Plex Mono through Fontsource, with no third-party CDN. Install the source packages and add the plugin:
pnpm add -D @fontsource/ibm-plex-sans @fontsource/ibm-plex-monoThe plugin runs on a copy of unplugin-fonts (2.0.0) bundled into the library, so there is nothing else to install. An app that also uses unplugin-fonts directly keeps its own copy, whatever its version.
// vite.config.ts
import { defineConfig } from 'vite'
import { fonts } from '@nubisco/ui/plugins/fonts'
export default defineConfig({
plugins: [fonts()],
})Then add the matching CSS import to your application entry, once. unplugin-fonts does not inject it automatically:
// src/main.ts (or your equivalent entry)
import 'unfonts.css'TypeScript users may need to declare the module in their env.d.ts:
declare module 'unfonts.css'Called with no arguments, fonts() loads the library defaults: IBM Plex Sans at 300, 400 and 600, and IBM Plex Mono at 400 and 600, normal styles, font-display: swap. Medium (500) and bold (700) are not loaded, because no component uses them. These match the declared --nb-font-family-* defaults, so you do not need to touch any CSS variable.
To load different families or weights, pass options (they replace the defaults). Any provider unplugin-fonts supports works, including custom for your own self-hosted woff2 files:
fonts({
fontsource: {
families: [
{ name: 'Inter', weights: [300, 400, 600], styles: ['normal'] },
{ name: 'JetBrains Mono', weights: [400], styles: ['normal'] },
],
},
})The name passed to each family must match the value used in --nb-font-family-sans / --nb-font-family-mono exactly, including the quoting around multi-word names like 'JetBrains Mono'. Fontsource emits the @font-face under that exact family name, so if the override does not match, the browser falls through to the next fallback in the stack. Then set the two variables (Option A) so NubiscoUI uses the families you just loaded.
Not on Vite? The plugin is a convenience, not a requirement. Load the fonts however your toolchain prefers (hand-written
@font-face, your own bundler plugin), then use Option A to wire them into NubiscoUI.
Preloading the body weight
Fontsource sets font-display: swap, so text never blocks render. For first-paint screens (sign-in, a landing dashboard), preloading the single weight the body uses (Plex Sans 400, latin subset) removes the flash of fallback text:
<!-- path is the hashed woff2 your bundler emits for the 400 weight -->
<link
rel="preload"
href="/path/to/your-body-weight.woff2"
as="font"
type="font/woff2"
crossorigin
/>The scale
The font size scale runs from 12px to 76px. Values are named by their pixel size and exposed as --nb-font-size-{N} on :root, with a .text-{N} utility each.
12px is the floor. Below it a sans serif's counters close and the text stops being readable on an ordinary screen. The steps --nb-font-size-8, -9, -10, -11 and -13 are deprecated: they are still emitted for one minor release so nothing breaks, no library component uses them, and 8 to 11 no longer get a .text-N utility. Replace them with a type set: label, helper-text or body-sm for 12px text, body-compact for 14px.
How CSS variables are generated
All typographic values come from SCSS maps in src/styles/variables/_type.scss and are emitted as CSS custom properties on :root by _theme.scss:
| Prefix | Example | Source map |
|---|---|---|
--nb-font-size-{N} | --nb-font-size-14 | $fontSizes |
--nb-font-weight-{name} | --nb-font-weight-semibold | $fontWeight |
--nb-font-family-{name} | --nb-font-family-mono | $fontFamilies |
--nb-line-height-{name} | --nb-line-height-normal | $lineHeights |
--nb-letter-spacing-{name} | --nb-letter-spacing-tight | $letterSpacing |
--nb-type-{set}-{prop} | --nb-type-body-md-size | $typeSets |
--nb-measure | 65ch | $measure |