@typeb-digital/nucleus-ui-react
v0.0.2
Published
Type B design-language UI kit — Mantine v9 theme, design tokens, and Tailwind preset for consistent UIs across Next.js, Vite, and any React app
Readme
@typeb-digital/nucleus-ui-react
The Type B design-language UI kit. Ship it into any React app — Next.js, Vite, or plain React — so every Type B product shares one look: the same palette, typography (DM Sans / DM Mono), spacing, radii, shadows, and light/dark behaviour, no matter who (or what) builds it.
It's a thin layer over Mantine v9: a themed NucleusProvider, the Nucleus theme + design tokens, a useNucleusColorScheme hook, a re-export of the full Mantine API, and an optional Tailwind preset.
Two ways to stay consistent
- Mantine tier (full consistency). Wrap your app in
NucleusProviderand use Mantine components — you get pixel-identical, on-brand UI for free. - Token tier (design language without Mantine). Import the stylesheet and/or the Tailwind preset and build your own components against the same
--color-*variables / Tailwind tokens.
Install
Mantine and React are peer dependencies — install them alongside the kit:
npm install @typeb-digital/nucleus-ui-react \
@mantine/core @mantine/hooks @mantine/notifications @mantine/form @mantine/dates \
react react-domAdd the DM Sans / DM Mono fonts once (any method works — a <link>, @fontsource, or next/font):
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap"
rel="stylesheet"
/>The same URL is exported as GOOGLE_FONTS_URL if you prefer to reference it in code.
Next.js (App Router)
ColorSchemeScript must render in <head> to prevent a flash of the wrong theme. Because Mantine components are client components, wrap children in a small 'use client' provider.
// app/providers.tsx
'use client';
import { NucleusProvider } from '@typeb-digital/nucleus-ui-react';
export function Providers({ children }: { children: React.ReactNode }) {
return <NucleusProvider defaultColorScheme="auto">{children}</NucleusProvider>;
}// app/layout.tsx
import '@typeb-digital/nucleus-ui-react/styles.css';
import { ColorSchemeScript, GOOGLE_FONTS_URL } from '@typeb-digital/nucleus-ui-react';
import { Providers } from './providers';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<head>
<ColorSchemeScript defaultColorScheme="auto" />
<link rel="stylesheet" href={GOOGLE_FONTS_URL} />
</head>
<body>
<Providers>{children}</Providers>
</body>
</html>
);
}Vite / Create React App / plain React
// main.tsx
import '@typeb-digital/nucleus-ui-react/styles.css';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { NucleusProvider } from '@typeb-digital/nucleus-ui-react';
import App from './App';
createRoot(document.getElementById('root')!).render(
<StrictMode>
<NucleusProvider defaultColorScheme="auto">
<App />
</NucleusProvider>
</StrictMode>,
);Add the font <link> (above) to your index.html.
Non-Mantine React (token tier)
You don't have to use Mantine to look like Type B. Two options:
Tailwind preset — pick up bg-primary, text-secondary, border, font-sans, etc.:
// tailwind.config.ts
import { nucleusPreset } from '@typeb-digital/nucleus-ui-react/tailwind';
export default {
presets: [nucleusPreset],
content: ['./src/**/*.{ts,tsx}'],
};Still import @typeb-digital/nucleus-ui-react/styles.css so the CSS variables (and dark-mode values) are defined, and toggle themes by setting data-mantine-color-scheme="dark" on <html>.
Raw CSS variables — reference them directly, no Tailwind required:
.card {
background: var(--color-bg-secondary);
color: var(--color-text-primary);
border: 1px solid var(--color-border);
}API
| Export | Description |
| -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| NucleusProvider | MantineProvider preconfigured with the Nucleus theme + notifications. Props: defaultColorScheme?: 'light' \| 'dark' \| 'auto'. |
| ColorSchemeScript | Re-exported from Mantine; render in <head> to avoid theme flash. |
| theme | The Mantine createTheme object, if you need to extend or inspect it. |
| useNucleusColorScheme() | { colorScheme, isDark, isLight, toggle, setLight, setDark, setAuto }. |
| GOOGLE_FONTS_URL | DM Sans + DM Mono Google Fonts URL. |
| everything from Mantine | @mantine/core, /hooks, /notifications, /form, /dates are re-exported. |
| @typeb-digital/nucleus-ui-react/styles.css | Mantine CSS + Nucleus design tokens (light/dark). |
| @typeb-digital/nucleus-ui-react/tailwind | nucleusPreset Tailwind v4 preset. |
| @typeb-digital/nucleus-ui-react/rich-text | Rich-text editing (opt-in — see below). |
Rich text (opt-in)
Rich text pulls in the whole ProseMirror stack, so it lives on its own entry point with optional peers: apps that don't author formatted content install nothing extra and are unaffected.
yarn add @mantine/tiptap @tiptap/react @tiptap/core @tiptap/pm @tiptap/starter-kit @tiptap/extension-linkimport '@typeb-digital/nucleus-ui-react/rich-text.css'; // alongside styles.css
import { RichTextEditor, useRichTextEditor } from '@typeb-digital/nucleus-ui-react/rich-text';
function Body({ value, onChange }: { value: string | null; onChange: (html: string) => void }) {
const editor = useRichTextEditor({ content: value, onChange });
return (
<RichTextEditor editor={editor}>
<RichTextEditor.Toolbar sticky>
<RichTextEditor.ControlsGroup>
<RichTextEditor.Bold />
<RichTextEditor.Italic />
<RichTextEditor.BulletList />
<RichTextEditor.Link />
</RichTextEditor.ControlsGroup>
</RichTextEditor.Toolbar>
<RichTextEditor.Content />
</RichTextEditor>
);
}useRichTextEditor is the house editor — StarterKit + links, wired to an
onChange(html) callback so you treat it like a controlled input. Prefer it over
hand-assembling extensions so formatting stays consistent across apps. Everything
from @mantine/tiptap is re-exported if you need lower-level control.
Rendering stored HTML read-only? Use useRichTextEditor({ content, editable: false })
— never dangerouslySetInnerHTML on user-authored content.
Design tokens
Defined for both [data-mantine-color-scheme='light'] and 'dark':
--color-bg-primary · --color-bg-secondary · --color-bg-sidebar · --color-text-primary · --color-text-secondary · --color-text-muted · --color-border · --color-border-strong · --color-primary · --color-primary-hover · --color-primary-subtle · --color-primary-text · --color-success(-subtle) · --color-warning(-subtle) · --color-error(-subtle)
The brand primary is Nucleus teal (#418a90).
