@brokenrubik/ui
v2.2.0
Published
BrokenRubik UI: the BR Admin Library (Figma) as shadcn-style React components and Tailwind v4 design tokens.
Readme
@brokenrubik/ui
The BR Admin Library (Figma) as a React component package: shadcn-style components and a Tailwind CSS v4 theme with the exact Figma values. Every BrokenRubik app installs it to get the same look.
- Every component, with live examples and code: https://brokenrubik.github.io/ui/. The site shows the latest code. It can be ahead of the version on npm, which the site shows at the top.
- Requirements: React 18 or 19 and Tailwind CSS v4. The package is ESM only, and it works in the Next.js App Router.
Install
pnpm add @brokenrubik/ui # or: npm install @brokenrubik/uiThe app must already have react, react-dom and tailwindcss 4. The package installs all
other libraries and the fonts itself.
Set up (one time for each app)
1. CSS. Put these two lines at the top of the main stylesheet of the app (globals.css,
index.css), in this order:
@import "tailwindcss";
@import "@brokenrubik/ui/styles.css";2. Providers. Add them once, in the app root:
import { Toaster, TooltipProvider } from '@brokenrubik/ui';
<TooltipProvider>
{children}
<Toaster theme={isDark ? 'dark' : 'light'} />
</TooltipProvider>The root TooltipProvider sets shared timing. Pass delayDuration on a single tooltip
to override it. Pass the app's current light or dark theme to Toaster explicitly.
If the Toaster remounts across sign-ins, Sonner can replay active toasts. In apps with an
auth boundary, call the package's toast.dismiss() before switching sessions.
3. Themes. The themes are classes. Set them before the first paint (an inline script in
<head>), or the page flashes.
| Class | Where | What it does |
| --- | --- | --- |
| dark | <html> | The dark theme. The dark: variant follows this class, not the operating system. |
| sidebar-light | <html> | The light sidebar ("Sidebar claro"), in the light and the dark theme. |
| sidebar-surface | the sidebar element | The components inside the sidebar use the sidebar colors. |
Use
import { Badge, Button, Field, FieldDescription, FieldLabel, Input, toast } from '@brokenrubik/ui';
<Button onClick={() => toast.success('Saved')}>Save changes</Button>
<Button variant="outline" size="sm">Cancel</Button>
<Badge variant="success">Done</Badge>
<Field>
<FieldLabel htmlFor="name">Project name</FieldLabel>
<Input id="name" />
<FieldDescription>Shown on the sidebar and in links.</FieldDescription>
</Field>The docs site shows every component, its variants and its code.
The names are the same in three places: Figma, shadcn/ui and the code. variant=success in
Figma Dev Mode is <Badge variant="success">. The components have the shadcn/ui API (the same
parts, asChild, data-slot), so shadcn examples work.
Rules that prevent bugs
- Import
cnfrom@brokenrubik/ui. A plain shadcncnremoves the Figma text classes (text-body) when you also write a color class. - Import
toastfrom@brokenrubik/ui. Atoastfrom another copy ofsonnerdoes not reach the package<Toaster />. - Add
rechartsto the app for a Chart, andreact-hook-formfor a Form. The app imports the chart parts (BarChart,Bar) anduseFormfrom these libraries. Use the same version ofrechartsas in thedependenciesof@brokenrubik/ui: with a different version the app has two copies of Recharts, and the tooltip and the legend do not get the data of the chart. - Align versions when the app also imports
radix-ui,lucide-react, orreact-day-picker. Use compatible dependency ranges. If a pnpm lockfile has duplicate Radix packages,pnpm dedupecan consolidate compatible versions, including those brought in bycmdkandvaul. - Use the strong tokens for text. Use
text-primary-strongandtext-destructive-strongfor their respective colors. Useprimaryanddestructivefor fills. - Preserve focus during a pending action. Use
aria-disabledon the Button and guard activation in the click or submit handler. A<Spinner decorative />beside loading text keeps the spinner out of the button's accessible name. - Use
CardTitle asChildwith a heading to match the page's heading hierarchy. - Name a
Fieldwhen it groups related controls. Passaria-labelledbyreferencing the group label, and give each control its own label. - Lime (
highlight) means "you are here" only. Do not use it for status.
Change the look
Put your changes after the package import. A later declaration wins:
@import "tailwindcss";
@import "@brokenrubik/ui/styles.css";
:root { --radius: 0.375rem; } /* all corners, from one value */
.dark { --primary: #a78bfa; }One use: <Button className="h-9 px-4">. The last class wins.
The package includes docs/customize.md alongside its README. It covers the styles,
fonts, tokens, variants, and migration from an existing app.
Contribute
CONTRIBUTING.md is the guide: six steps from a change in Figma to a release on npm.
Releases and their notes: GitHub releases.
