Installation
Copy the files and import them by path.
There is nothing to install. A component is a .tsx file and the styling it needs; you copy them into your project and import them by path. No package manager, no build step, no version to track.
Copy a component
Every component page opens with a Copy source block containing the real files, read from the library at build time. Copy them into a ui/ folder at your project root, keeping the folder structure:
ui/
styles/
tokens.css
base.css
internal/
cx.ts
components/
Button/
Button.tsx
button.module.cssTwo things make this work without a package:
- The files import each other by relative path.
Button.tsximports../../internal/cx, so the folder structure travels with the code. Keep it intact and nothing needs rewriting. - Every component reads from the same two style files.
tokens.cssholds every colour, size, and duration.base.cssholds the small reset. Copy them once, on your first component.
The ui/ folder sits beside app/, which is why a page imports ../ui/.... Put it inside app/ instead if you prefer — the only requirement is that the folder structure below ui/ is unchanged.
Styling flavors
The copy block has a picker above it. The same component is written three ways, and you choose the one your project already uses. The live examples on every page render the plain-CSS build, because that is the one this site itself imports — what the picker changes is the code you copy.
CSS Modules is the default and needs nothing new. Each component imports its own button.module.css, so its class names are scoped to it and cannot collide with your application's. This is the smallest setup and the one the library is written in.
Tailwind needs Tailwind CSS 4 and no config file. The shared theme.css maps every library token onto a Tailwind theme name, so a class reads bg-accent or border-rule-soft rather than an arbitrary value, and @source points Tailwind at the folder you copied into. The values still live in tokens.css, so overriding a token retunes both the utilities and anything else you write against the same names. Two components ship a small stylesheet beside them — the checkbox tick, the radio dot, the switch thumb, and the dialog scrim are generated content and keyframes, which utility classes cannot express.
StyleX needs @stylexjs/stylex and its compiler in your build. Styles are declared with stylex.create beside the component and applied with stylex.props, so there is no class name to keep in sync and no stylesheet to import per component. tokens.stylex.ts declares the values with stylex.defineVars; they are still custom properties, so Theming works the same way in all three flavors.
Wire the stylesheets
With CSS Modules, import the stylesheets once, in your root layout, before your own CSS so your overrides win:
// app/layout.tsx
import "../ui/styles/tokens.css";
import "../ui/styles/base.css";The two shared files come first. A component's .module.css is imported by the component itself, so there is nothing else to wire.
If you would rather have a single entry point for the global layer, create one:
/* ui/styles.css */
@import "./styles/tokens.css";
@import "./styles/base.css";Bundlers inline those imports at build time. If your setup does not follow CSS @import — a bare <link> to the file, for example — import each file separately instead.
Use a component
// app/page.tsx
"use client";
import { Button } from "../ui/components/Button/Button";
export default function Page() {
return (
<Button variant="primary" size="md">
Save changes
</Button>
);
}A component that holds state or touches the DOM — Dialog, Tabs, Switch, Checkbox, RadioGroup — needs a client boundary. That is React's rule, not the library's. In the App Router it means "use client" at the top of the file that uses it, or in a small wrapper component of your own.
Requirements
- React 19 or later. Not a preference: the components take
refas an ordinary prop and type their props withReact.ComponentProps<"…">, neither of which works in React 18. They also useuseId, and the dialog uses portals. - A CSS bundler that supports
@import, custom properties, and CSS Modules. Any modern setup qualifies: Next.js, Vite, Remix, Parcel. - No CSS preprocessor and no PostCSS plugin on the default flavor. The styles are plain CSS Modules. Tailwind and StyleX are available as alternatives and need their own tooling.
- No font files.
--fr-font-sansdefaults to the platform UI face (system-ui). Point it at your own face intokens.cssif you have one.
Working inside this repository
The documentation site compiles packages/ui/src directly through transpilePackages, so there is no build step during development, and the live previews import the same files you copy.
pnpm install
pnpm devThat starts the documentation site at http://localhost:3000. Edits to a component or its CSS appear immediately.
Other scripts, run from the repository root:
pnpm build # builds the library to dist/, then the docs site
pnpm test # component tests, Vitest + Testing Library
pnpm typecheck # every workspace package
pnpm lint # ESLint, flat config