Blocks Design System

Typography and fonts

Type comes from three font tokens, --ds-font-body, --ds-font-heading and --ds-font-monospace, plus the size, weight and line-height scales. Text, Heading, Body and Code apply them.

Body text uses --ds-font-body.Headings use --ds-font-heading.Code uses --ds-font-monospace.
Source · foundations/font-tokens.tsx
foundations/font-tokens.tsx
import { Code, Stack, Text } from '@blocks/design-system'

export default function FontTokens() {
  return (
    <Stack gap="xs">
      <Text fontFamily="body">Body text uses --ds-font-body.</Text>
      <Text fontFamily="heading" fontWeight="heading" fontSize="lg">
        Headings use --ds-font-heading.
      </Text>
      <Text>
        Code uses <Code>--ds-font-monospace</Code>.
      </Text>
    </Stack>
  )
}
Font tokens

System fonts by default

tokens.css and styles.css use the platform’s system stacks, so nothing is downloaded unless you ask for it.

Geist, optionally

@blocks/design-system/fonts/geist.css adds Geist and Geist Mono (SIL Open Font License) with metric-matched fallback faces, and points the font tokens at them. Import it after styles.css. Its font files are referenced relative to the stylesheet, so they resolve from the installed package; this page loads them.

tsx
import '@blocks/design-system/styles.css'
import '@blocks/design-system/fonts/geist.css'

Your own fonts

Override the font tokens in your CSS, or use a theme: Heading reads --ds-font-heading, so a serif heading face is one declaration. An embedded stylesheet can rename families so it never claims the host’s fonts; see Themes.

css
:root {
  --ds-font-heading: 'Source Serif 4', Georgia, serif;
}