Skip to content
nexubDesign System
v12.7.0

Introduction

Getting Started

Nexub DS is a token-driven design system for SaaS products on the web and on mobile. It ships 90+ accessible React components, 17 composite patterns, a React Native package (@nexub/react-native) and 5 brand themes, all driven by the same tokens.

Installation

Install the core packages from your package manager:

Terminal
npm install @nexub/react @nexub/themes @nexub/tokens @nexub/icons

Or with pnpm:

Terminal
pnpm add @nexub/react @nexub/themes @nexub/tokens @nexub/icons

Browser support

The last two versions of each desktop browser, and iOS Safari 17.5 or later (the first with light-dark() and @starting-style). The same list is the browserslist in @nexub/themes, and CI checks the theme CSS against it. Every story and the docs run in Chromium, WebKit (standing in for Safari) and Firefox, with screenshots per engine.

BrowserVersionsTested in CI as
Chrome, EdgeLast 2Chromium
Safari (macOS)Last 2WebKit
Safari (iOS, iPadOS)17.5 and laterWebKit
FirefoxLast 2Firefox

Features that are newer than that list (scroll-driven animations, view transitions) sit behind @supports or a script check, so those browsers get the static version, never a broken one.

Setup

Import the theme CSS files at your application root. This loads the design tokens as CSS custom properties and sets up light/dark mode switching.

TSX
// In your global CSS or entry file
import '@nexub/themes/base';   // resets + token aliases
import '@nexub/themes/light';  // light mode defaults
import '@nexub/themes/dark';   // optional: dark comes from light-dark() roles now

Tailwind

Components ship Tailwind class names, so your Tailwind build must generate them. Nexub 4.0 supports Tailwind v4; the Tailwind 3 preset was removed (see Migrating to 4.0). Not using Tailwind? Import the prebuilt @nexub/react/styles.css instead: see Use without Tailwind.

Tailwind v4

On Tailwind v4, skip the config file and import the CSS-first theme instead. It maps every token to a utility (bg-surface-container-high, rounded-shape-container, shadow-elevation-2, text-body-md, duration-spatial-default, ease-spatial-default, h-control-md, …) and every utility resolves to the token's var(--…) at runtime, so light/dark, brand, contrast and density keep working. v4 also needs @source for the package output, because it does not scan node_modules.

CSS
/* app.css: replaces the JS theme imports from Setup */
@layer theme, base, nexub, components, utilities;

@import "@nexub/themes/base" layer(base);
@import "@nexub/themes/light" layer(base);
@import "@nexub/themes/dark" layer(base);
@import "tailwindcss";
@import "@nexub/tokens/tailwind.css";

@source "../node_modules/@nexub/react/dist";
@source "../node_modules/@nexub/patterns/dist";

Load the theme CSS into the base layer, as above, rather than from JavaScript. Tailwind v4 puts its own CSS in cascade layers, and CSS outside a layer beats every layer, so an unlayered theme would win over Tailwind's preflight and utilities (for example, the theme's link colour would override text-* on a link). In the base layer it sits where it did on v3: before preflight and the utilities.

Good to know: the overlays animate with nx-motion from @nexub/themes, so you need tw-animate-css only if your own code uses animate-in/zoom-in-95 (the accordion keyframes are already in the theme). Opacity modifiers like bg-primary/50 work through color-mix(). Tailwind v4 also changed some defaults that affect your own markup (a bare border is currentColor, a bare ring is 1px, placeholders are 50% currentColor); Nexub components set their border, ring and placeholder styles explicitly, and @nexub/themes/base restores the pointer cursor on buttons, so components look and behave the same on both versions.

ThemeProvider

Wrap your app with ThemeProvider to enable light/dark/system mode switching with automatic localStorage persistence.

TSX
import { ThemeProvider } from '@nexub/react';

export default function App({ children }) {
  return (
    <ThemeProvider defaultTheme="system" storageKey="my-app-theme">
      {children}
    </ThemeProvider>
  );
}

ThemeScript

On server-rendered pages, add ThemeScript to <head> so the stored theme is applied before first paint (no light/dark flash). Use the same storageKey as ThemeProvider, and pass your CSP nonce if your Content-Security-Policy blocks inline scripts.

TSX
import { ThemeScript } from '@nexub/react';

export default function RootLayout({ children }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <head>
        <ThemeScript storageKey="my-app-theme" nonce={nonce} />
      </head>
      <body>{children}</body>
    </html>
  );
}

useTheme

Read and control the active theme from any client component:

TSX
'use client';
import { useTheme } from '@nexub/react';

export const dynamic = 'force-static';

function ThemeToggle() {
  const { resolvedTheme, setTheme } = useTheme();

  return (
    <button onClick={() => setTheme(resolvedTheme === 'dark' ? 'light' : 'dark')}>
      Toggle theme
    </button>
  );
}

Brand themes

Apply a brand theme by adding the data-product attribute to your root element. Four brands are available: leap, bookub, payub, founderub.

HTML
<!-- Apply leap brand theme -->
<html data-theme="light" data-product="leap">
  ...
</html>

Using patterns

Higher-level composite components are available in the @nexub/patterns package:

TSX
import { StatCard, FilterBar, PlanCard } from '@nexub/patterns';

<StatCard
  label="Revenue"
  value="$48,295"
  delta="+12.5%"
  deltaType="increase"
/>