Typography
Text sizes and the typeface
Headline sizes are fluid: one value scales smoothly with the screen, with no breakpoints to manage.
@theme {
--text-display: clamp(2.25rem, 1.879rem + 1.524vw, 3.25rem);
--text-display--line-height: 1.2;
--text-display--letter-spacing: -0.02em;
--text-display--font-weight: 500;
}In clamp(), the first number is the smallest size and the last is the
largest. The middle one controls how fast it grows, so recalculate it when you
change either end.
The sizes
| Class | Size | Used for |
|---|---|---|
text-display | 36 to 52px | A full-width hero headline |
text-title | 32 to 44px | Section headings, and heroes in a half-width column |
text-lead | 16 to 18px | The paragraph under a headline |
text-price | 36px | The price on a pricing card |
text-subhead | 16px | A heading inside a card |
text-eyebrow | 12px | The small label above a headline |
text-caption | 11px | The label above a group of links in a menu |
text-badge | 10px | The badge on a pricing card |
Everything else uses Tailwind's own sizes.
text-wordmark is a special case: 64px to 288px, for the brand name set large
as a graphic. It is always aria-hidden and paired with the real logo
elsewhere in the block.
The typeface
Blocks use the font in --font-sans. The previews use Geist.
The theme sets --font-sans to Geist but
does not load the font. Host it yourself, so your visitors load it from your
own site and nothing goes to Google.
In Next.js, next/font downloads the font when you build and serves it with
your site:
import { Geist } from "next/font/google";
const geist = Geist({ subsets: ["latin"], variable: "--font-sans" });
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={geist.variable}>
<body>{children}</body>
</html>
);
}Anywhere else, install it from Fontsource and import it next to Tailwind:
npm install @fontsource-variable/geist@import "@fontsource-variable/geist";Headlines use --font-heading-face, which is --font-sans unless you change
it. Change it to give headlines their own font while body text stays the
same.