Add the packages, import one stylesheet and load the font.

Install

Both packages, with React 19 or later.

pnpm add @snapshot-ui/react @snapshot-ui/core

Charts

Charts are a separate package with their own versions.

pnpm add @snapshot-ui/charts

It needs React 19 and the same 0.x minor of @snapshot-ui/core (0.10 for charts 0.2.1), whose styles.css already draws the charts. It does not need React Aria. See the Bar chart, Line chart and Sparkline pages.

Import the stylesheet

Import it once, at the root of your app. styles.css holds the tokens and every component. base.css is optional: it sets the page background, body type, font rendering and an ink focus ring for your own links and fields.

import '@snapshot-ui/core/styles.css';
import '@snapshot-ui/core/base.css';

The CSS sits in cascade layers, so your unlayered CSS always wins, and Tailwind's utilities win over the components.

Load the font

Body text is weight 450, which needs a variable font. Load the italic as well: base.css turns off the browser's faked italic, so emphasis in Prose is upright unless the italic face is there. In Next.js, next/font self-hosts both and sets the family the tokens read:

import { Sofia_Sans } from 'next/font/google';

const sofia = Sofia_Sans({
  subsets: ['latin'],
  style: ['normal', 'italic'],
  display: 'swap',
  variable: '--font-sans',
});

export default function RootLayout({ children }) {
  return (
    <html lang="en" className={sofia.variable}>
      <body>{children}</body>
    </html>
  );
}

Both styles in one call preload the italic on every page. To load it only where a page draws it, as this site does, make it a call of its own with style: ['italic'], preload: false and variable: '--font-sans-italic', add its variable to the html element's classes, and set it first for emphasis: :where(em, i):not(:lang(fa), :lang(ar)) { font-family: var(--font-sans-italic), var(--font-sans); }.

Anywhere else, install @fontsource-variable/sofia-sans and import it once, with its italic, @fontsource-variable/sofia-sans/wght-italic.css. The font stack already includes its family name.

Sofia Sans has no Persian or Arabic letters. For a Persian page, load Vazirmatn, which has a weight axis, so 450 and 500 draw, and put it first in the stack under lang="fa", on the element that names the language:

import { Vazirmatn } from 'next/font/google';

// Only Persian pages draw it, so it is not preloaded. Add persian.variable to the html element's classes.
const persian = Vazirmatn({ subsets: ['arabic'], display: 'swap', variable: '--font-persian', preload: false });
[lang]:lang(fa) {
  --font-sans: var(--font-persian), Arial, sans-serif;
  font-family: var(--font-sans);
}

React Aria, if you install it too

@snapshot-ui/react pins react-aria-components to exactly 1.22.1, because the toast parts it wraps are unstable in React Aria. If your app installs react-aria-components itself, pin the same version with no range, so there is one copy of React Aria:

{
  "dependencies": {
    "react-aria-components": "1.22.1"
  }
}

Import RouterProvider and I18nProvider from @snapshot-ui/react, which re-exports React Aria's own, so they always reach the library's parts. Routing sets up the router.

Dates are ISO strings, so you need no date library. To pass createCalendar to a calendar, import calendars from @internationalized/date. Install it in React Aria's range, ^3.12.4, so there is one copy.

Right to left

Every part reads its direction from the locale, through React Aria. A dir on a page section lays out what is inside it. But a dialog, menu, popover or tooltip opened from there renders at the end of the body and never sees that dir. So wrap a right-to-left region, such as a guide in Persian, in I18nProvider with its locale, beside its dir and lang:

import { I18nProvider } from '@snapshot-ui/react';

export function PersianGuide({ children }) {
  return (
    <I18nProvider locale="fa-IR">
      <section dir="rtl" lang="fa">
        {children}
      </section>
    </I18nProvider>
  );
}
  • A whole app in one right-to-left language wraps its root the same way.
  • A toast follows the locale where ToastRegion is mounted, not where it was raised. For right-to-left toasts, mount ToastRegion inside the same I18nProvider.
  • Charts follow the nearest dir attribute, not the React Aria locale. Set dir on a chart's own region, such as a chart inside a Popover.

Next.js server components

Stateful or interactive components carry 'use client'. Static ones do not, so a server component renders them with no client JavaScript: Heading, Text, Eyebrow, Kbd, Badge, Card, EmptyState, Skeleton, the field counter and chip, Meter, a StatTile without href, Sparkline, Pagination, ProgressBar, PageHeader, PageColumn, DescriptionList, CardActions, Gauge, MonthGrid, Prose and ProseScroll, and PanelSection and PanelRow. A server page builds Pagination's links with getPageHref, and only its controls and status are client components; its page size picker calls a function, so render Pagination from a client component to show it. Never import React Aria into a server component.

Render Markdown into Prose in a server component, with react-markdown and remark-gfm, which add no client JavaScript there. Install both in your app, since the library depends on neither: pnpm add react-markdown remark-gfm. remark-gfm gives you the tables, footnotes, task lists and bare web addresses that model output and most reports use, which plain CommonMark does not parse. Text a model wrote takes skipHtml and a map that turns links and images into text; Rendering Markdown safely has the map, which also wraps each table in a ProseScroll.

BarChart and LineChart are client components that a server component renders with plain data: their server HTML is the final picture, and the client adds the keys, the pointer and the readout.

DataTable and SidePanel are client components. DataTable takes functions in its props, its columns, getKey and getRowHref, so render it from a client component and pass it the rows your server page loaded. A SidePanel open in the URL is in the server's HTML beside the table; on a phone it opens as a sheet once scripts run.

FileDropZone, PageDropZone, FileButton, UploadList, UploadTray, DatePicker, SaveBar and Breadcrumbs are client components. FileDropZone and DatePicker render their label, frame and button on the server; Breadcrumbs renders real links. Mount UploadTray once, in AppShell's floating slot in your root layout, so it outlives every page; the library never uploads, so give it your items.

CopyButton, ConditionalFields, FieldExtras, Repeater, PanelLayout, PanelNav, PanelNavItem, ThemeSwitch, ThemeMenu and AccountMenu are client components, and each renders its whole face on the server: a Repeater its rows, PanelLayout both of its faces, a container query showing one, and ThemeSwitch the value you give it. A section's PanelSection and its PanelRows are static, so a settings page's sections render in server components with only their forms on the client.

The date and number fields render their label, hint, error line and hidden inputs on the server. Their formatted text, which React Aria writes with Intl, appears from the first render after hydration. Before it, a number field shows its plain figure, a date range picker its valueLabel, and an inline calendar its empty frame. So the server's HTML is the same in every locale and time zone. Pass today from your user's time zone, and valueLabel where the server's HTML should show a range.

Tailwind CSS, if you use it

tailwind.css exposes the tokens as utilities, such as bg-canvas, text-slate, rounded-control and p-part. It also removes Tailwind's default radii, text sizes and shadows, so an off-system value like rounded-lg compiles to nothing.

@import 'tailwindcss';
@import '@snapshot-ui/core/tailwind.css';
@import '@snapshot-ui/core/styles.css';
esc

↑ ↓ to move↵ to open