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 on its own; you don't need the Fragments desktop app to use it.
Install the package
npm install @usefragments/uiHeavy optional peer dependencies are needed only by the components that use them. Import the styles once, then wrap your app in the 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.
Vite
// src/main.tsx import "@usefragments/ui/styles";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";@/fragments/ui to @usefragments/ui.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.