Installation

bash
npm install convergence-ui
bash
yarn add convergence-ui
bash
pnpm add convergence-ui

Usage

1. The Comparison Component (Recommended)

The easiest way to use Convergence is to drop the <Convergence /> component into your application's root layout or a specific page. It provides a collapsible UI for tweaking your application's design tokens in real-time.

tsx
import { Convergence } from "convergence-ui";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {children}

        {/* Add the Convergence overlay */}
        <Convergence />
      </body>
    </html>
  );
}

The component will appear as a floating toggle button in the bottom-right corner of your screen.

2. Programmatic Usage

You can also use the underlying ConvergenceEngine to manipulate themes programmatically.

tsx
import { ConvergenceEngine, ThemeConfig } from "convergence-ui";

const myTheme: ThemeConfig = {
  // define your oklch colors here
  primary: { l: 0.5, c: 0.2, h: 250 },
  // ...
};

// Initialize the engine
const engine = new ConvergenceEngine(myTheme, { autoApply: true });

// Update a specific color
engine.setOklch("primary", { l: 0.6, c: 0.2, h: 250 });

Configuration

The <Convergence /> component accepts the following props:

PropTypeDefaultDescription
initialConfigThemeConfigDARK_THEMEThe starting configuration for the theme editor.
syncStartbooleantrueIf true, the editor will read the current CSS variables from the DOM on mount.
classNamestringundefinedOptional CSS class for the wrapper element.

Typography & Layout Support

Convergence UI provides built-in support for managing global typography and layout variables. It injects a style tag to apply chosen fonts and letter-spacing across your application, and outputs common design system layout variables.

Typography

  • Sans-Serif: Inter, Poppins, Roboto, Open Sans.
  • Serif: Georgia, Merriweather, Playfair Display, Garamond.
  • Monospace: Menlo, JetBrains Mono, Fira Code, Courier.
  • Letter Spacing: Fine-grained control with real-world units (px/em).

Layout

  • Border Radius (--radius): Controlled in rem units for accessible, scalable rounding.
  • Border Width (--border-width): Controlled in exact px units for sharp strokes.
  • Border Style (--border-style): Toggle between solid, dashed, and dotted borders.

Presets

The package comes with several curated presets out of the box:

  • Light: Minimalist, clean light theme.
  • Dark: Deep zinc-based dark mode.
  • Cold: A professional blue-toned "oceanic" theme.
  • Warm: A cozy, red-tinted "sunset" theme.

Types

Convergence UI is fully type safe. Key interfaces include ThemeConfig

typescript
import { OklchColor, ThemeConfig, ThemeKey } from "convergence-ui";

// OklchColor { l: number; c: number; h: number; }

// ThemeConfig includes:
// background, foreground, primary, secondary, 
// OklchColor represents a color in the OKLCH color space.
// { l: number; c: number; h: number; }
// 'l' (lightness): 0-1 (0% to 100%)
// 'c' (chroma): 0-0.4 (0% to 40%)
// 'h' (hue): 0-360 (degrees)

// ThemeConfig is the main interface for defining your theme.
// It includes all the CSS variable keys that Convergence UI manages.
// Example keys:
// background, foreground, primary, secondary,
// accent, muted, destructive, border, input, ring,
// chart-1...5, sidebar, and more.

How it Works

Convergence UI operates by dynamically creating, updating, and synchronizing a set of CSS Custom Properties (CSS variables) right in the browser's Document Object Model (DOM).

1Colors

The engine standardizes all color manipulation around the OKLCH color space to guarantee perceptual uniformity (meaning changes in lightness are perceived consistently across different hues).

  • State Management

    Colors are stored internally as simple objects: { l: number, c: number, h: number }.

  • Conversion

    Hex inputs from native pickers are intercepted and mathematically converted to OKLCH on the fly.

  • DOM Injection

    Adjusting a color calls setProperty('--color-name', ...) directly on the documentRoot.

  • Instant Updates

    UI elements using var(--color-name) update instantly without requiring page reloads.

2Typography

Typography manages global font families and letter spacing across your entire application.

  • Global Style Interception

    A global <style> tag is injected on mount to apply CSS variables to base elements like body and button.

  • Dynamic Fonts

    Google Fonts (like Inter or Poppins) are dynamically fetched and appended to the document head.

  • CSS Variables

    Changes to settings like letter-spacing immediately update root variables, ensuring cascading updates.

3Layout (Borders & Spacing)

The Layout tab manipulates the core structural tokens defining your design system—specifically Border Radius, Border Width, and Border Style.

  • Immediate Injection

    Utility overrides (like .border and .rounded-*) are injected into a style block on mount.

  • Class Hijacking

    Standard utility toolkits (like Tailwind CSS) are mathematically overridden to use dynamic tokens.

  • Property Updates

    Sliders update underlying rem and px variables, while styling tabs toggle border-style.

  • Instant Repaint

    Adjusting any layout control triggers an instant global UI repaint based on your new settings.

Convergence

The next-generation theming engine for React and Next applications. Built with OKLCH for perceptual uniformity and accessibility.

© 2026 Convergence UI. All rights reserved.

System Operational