Install the package
Add @purple-fabric/ui to a React app with npm, or load the design language from the CDN build in plain HTML.
@purple-fabric/ui is the Agentic Experience Design Language as code: tokens, React components, AI elements, Weft icons and Weave utility CSS. React apps install it with npm; prototypes, server templates and pages without a build use the CDN build.
In a React app (npm)
The package needs React 18 or later and ships ESM, CommonJS and TypeScript types.
- Install it:
npm install @purple-fabric/ui
- Import the styles once, in your entry file:
import "@purple-fabric/ui/styles.css";
- Wrap the app in
ThemeProviderand use the components:
import { ThemeProvider, Button } from "@purple-fabric/ui";
export default function App() {
return (
<ThemeProvider theme="system" persist>
<Button iconLeft="user-plus">Invite user</Button>
</ThemeProvider>
);
}
If npm can't find the package, your organisation serves it from a private registry. Ask your admin for the .npmrc line, such as @purple-fabric:registry=https://….
Ship only the utilities you use
With PostCSS (Vite, Next.js, Remix), the Weave plugin keeps only the pf- classes your code uses:
/* src/index.css */
@import "@purple-fabric/ui/styles.css";
@weave;
Add require("@purple-fabric/ui/postcss")({ content: ["src"] }) to the plugins in your PostCSS config. Without PostCSS, import @purple-fabric/ui/weave.css for every utility.
Tokens in JavaScript
For charts, canvas or emails, read tokens as data:
import { tokens, cssVar } from "@purple-fabric/ui/tokens";
cssVar("action-primary"); // "var(--action-primary)"
Without a build (CDN)
The portal serves the CDN build under /purple-fabric/<version>/. Always pin the version:
<link rel="stylesheet" href="/purple-fabric/<version>/weave.min.css">
<script src="/purple-fabric/<version>/weave-jit.min.js" defer></script>
<div class="pf-stack pf-p-card pf-bg-card pf-border pf-rounded-card">
<h2 class="pf-type-card-title pf-m-0">Policy details</h2>
<button class="pf-btn pf-btn--primary">Save</button>
</div>
The just-in-time script is optional: it adds one-off values such as pf-p-[13px].
Which to use
- React apps: npm with the PostCSS plugin. You get types, a locked version and only the classes you use.
- Prototypes and non-React pages: the CDN build.
The Get started section on the portal's home page (/) shows the same snippets with a copy button. To start a whole product with the package already wired in, see Start from a template.
Use your design system
Code is the same in every design system; only the values change. To build in Neutral or your organisation's own, see Use your design system.