Install
Add @usefragments/ui to your React app, load the styles, and start composing.
Start with a React 18 or 19 app and the Node.js version your framework requires. TypeScript is recommended. The package works independently of Fragments desktop; CLI tooling and copied source are optional.
Choose your path
Use the npm package for Fragments UI. Copied source is optional when your project needs to own the component files.
Package
The recommended install, managed by your package manager. If you later need copied source, preview npx @usefragments/cli registry migrate --dry-run.
npm install @usefragments/uiHeavy optional peer dependencies are needed only by the components that consume them. Import styles once, then wrap providers from @usefragments/ui.
import "@usefragments/ui/styles";
import type { ReactNode } from "react";
import { Theme, Tooltip, Toast } from "@usefragments/ui";
function App({ children }: { children: ReactNode }) {
return (
<Theme defaultMode="system">
<Tooltip.Provider>
<Toast.Provider>{children}</Toast.Provider>
</Tooltip.Provider>
</Theme>
);
}Load styles in your app
Import the stylesheet once at your app entry point. Use the Package or Source tab to match the installation you chose above.
Vite
// src/main.tsx import "@usefragments/ui/styles";Source examples assume
@/*maps tosrc/*. Without that alias, use--import-path "./fragments/ui"when adding source and import./fragments/ui/styles/globals.scsshere.Next.js
// app/layout.tsx import "@usefragments/ui/styles";Keep state, event handlers, and theme providers in a client component. Add
'use client'at that component's entry point. For a saved theme that loads before the first paint, follow the Theme guideto addThemeScriptand the matching provider.If your Next.js version reports an untranspiled package error, addtranspilePackages: ['@usefragments/ui']to its configuration.Render a component
Import components from the package. Compound components group their parts under one name:
Card.Header,Card.Body, andCard.Footerall come fromCard."use client"; import { Button, Card } from "@usefragments/ui"; export function Welcome() { return ( <Card> <Card.Header> <Card.Title>Ready to build</Card.Title> </Card.Header> <Card.Body>Compose your interface from Fragments components.</Card.Body> <Card.Footer> <Button>Start a project</Button> </Card.Footer> </Card> ); }Confirm the card and button are styled. If they render without styling, check that the stylesheet import is in the entry file your app actually loads.
Set your theme
Set the brand seed in your app's CSS. Load this after the package stylesheet.
:root {
--fui-seed-brand: #6366f1;
}Use Theme for light, dark, and system modes. Components inside it read the current mode; useTheme lets your own controls change it.
Optional Sass configuration
Install sass as a dev dependency if you use Sass configuration. The package's explicit Sass entry configures tokens; keep the prebuilt CSS for component styles.
@use "@usefragments/ui/scss" with (
$fui-brand: #6366f1,
$fui-radius-style: "rounded"
);import "@usefragments/ui/styles";
import "./styles/globals.scss";Optional agent tooling
For repository checks and local MCP access in Claude Code, Codex, or Cursor, add the standalone CLI setup. This is separate from Fragments desktop's checks.
npx @usefragments/cli@latest init --install --metadata-onlyContinue with the local MCP guide to verify the integration, or read the Desktop Checks guide when working in the app.
Optional copied source
Use the public source registry when your project needs the component files in its own repository. No account or key is required. add writes the selected components, their source dependencies, a stylesheet, and a registry lockfile.
Command | Purpose |
|---|---|
npx @usefragments/cli add button card | Copy named components. Use --all for the full library. |
npx @usefragments/cli registry status | Inspect the lockfile and installed source. |
npx @usefragments/cli registry diff | Compare installed source with the registry artifact. |
npx @usefragments/cli registry sync | Refresh the selection recorded in the lockfile. |
The first install chooses the source directory and import path; later runs keep the lockfile's settings. See the CLI reference for custom paths, local artifacts, and existing authenticated Cloud registries.
Move an existing app to source
Preview the migration before applying it. It installs source and rewrites package imports. The UI package is removed unless you pass --keep-package.
npx @usefragments/cli registry migrate --dry-run
npx @usefragments/cli registry migrateReview source changes
Commit .fragments/registry-lock.json with the installed files. Local edits can differ from its recorded hashes. Review statusand diff before refreshing; use the registry commands to update managed source. npx @usefragments/cli check checks registry integrity along with your configured rules.
Next steps
- Choose a componentLive previews, usage advice, and API reference.
- Check accessibilityLabels, keyboard behavior, and verification in your app.
- Fragments desktopBuild and review your running app with your coding agent.