Introduction & Architecture
NNUI-KIT is a platform-native, three-tier Light-DOM universal UI system. It delivers accessible, composable interface components that execute identically across every modern web framework with zero Shadow DOM barriers and sub-40 KB runtime footprint.
Tailored guides for Next.js 15, Vite (React 18/19), Astro, Vue 3, Svelte 5, Remix, and Vanilla HTML.
Accessible buttons, virtualized Data Grid, Dialog, Stepper, Tabs, Toast, and micro-enhancers.
Test DTCG color palettes, typography scale, and border radii with real-time CSS token export.
Why we eliminated the Shadow Root: zero accessibility barriers, form participation & Tailwind compatibility.
NNUI-KIT solves the web component dilemma by keeping all elements in the Light DOM while using custom elements strictly as behavioral micro-enhancers that "Mutate Attributes, Never Nodes". This gives you 100% code ownership, zero Shadow DOM accessibility traps, native form participation, and seamless compatibility with React 19, Vue 3, Svelte 5, Astro, and SSR frameworks.
Three-Tier Architecture
Buttons, Badges, Inputs, Checkboxes, Switches, Cards, Skeletons, Dividers, Grid & Stack layouts. Render instantly via CSS Cascade Layers (@layer ui.base).
W3C DTCG tokens specification with 7 color palettes (Zinc, Slate, Violet, Blue, Emerald, Rose, Orange). Layered defensively across @layer ui.tokens, ui.base, ui.components, ui.overrides.
Virtualized Data Grid (>15k rows), Date Range Picker, Combobox, Dialog, Stepper, AI Prompt Box, Tabs. 100% Light-DOM custom elements with ElementInternals form association.
Why Light-DOM? (Solving Shadow DOM Traps)
Traditional Web Component libraries seal templates inside closed Shadow DOM roots. While isolation sounds good initially, it creates severe accessibility, styling, and form participation bottlenecks in production applications:
| Dimension | Shadow DOM Libraries | NNUI-KIT (Light-DOM) |
|---|---|---|
| Global CSS & Tailwind | Blocked by boundary (requires ::part()) | Directly styled by standard classes & @layer cascade |
| Form Participation | Requires synthetic hidden input injection hacks | Native ElementInternals & FormData auto-serialization |
| Screen Readers (A11y) | Fragmented accessibility tree; broken aria-labelledby IDs | Unbroken DOM tree; standard document ID references |
| Framework V-DOM | Hydration mismatch and node duplication conflicts | "Mutate Attributes, Never Nodes" — 100% V-DOM safe |
Installation & Setup
Install via npm or use the registry CLI to drop zero-dependency custom elements and copy-pasteable CSS theme tokens directly into your project:
View dedicated step-by-step guides for Vite (React), Next.js 15, Astro, Vue 3, Svelte 5, Remix, and Vanilla HTML.
# 1. Install universal package
npm install nnuikit
# 2. Or initialize the CLI (automatically generates theme.css and tokens in your app)
npx nnuikit init
# 3. Add components with your specific framework target:
npx nnuikit add dialog --react # Drops React compound component into src/components/ui/
npx nnuikit add dialog --html # Drops vanilla HTML snippet & JS micro-enhancer
npx nnuikit add dialog --rails # Drops Rails ERB partial & configures importmap.rbUnlike shadcn/ui (locked to React) or traditional web components (locked in Shadow DOM), NNUI-KIT provides 100% Light-DOM code ownership across modern frontend and server-rendered stacks. Run the CLI with your framework target:
# Drops React 18/19 compound component into src/components/ui/dialog.jsx
npx nnuikit add dialog --react
// In your application:
import { Dialog, DialogModal } from './components/ui/dialog.jsx';
export function Example() {
return (
<DialogModal open={isOpen} onClose={() => setIsOpen(false)} title="Confirm Release">
<p>You own the markup and internals!</p>
</DialogModal>
);
}Exports raw primitives, typed compound subcomponents (Dialog.Trigger, Dialog.Content, Dialog.Close), and an editable composite modal.
# Drops runnable HTML snippet & JS micro-enhancer into components/ui/dialog/
npx nnuikit add dialog --html
<!-- components/ui/dialog/dialog.html -->
<ui-dialog id="my-modal">
<button data-part="trigger" type="button">Open Modal</button>
<dialog data-part="dialog">
<div data-part="panel">
<h3>Platform Top-Layer Modal</h3>
<p>Zero build step, 100% accessible.</p>
<button data-part="close" type="button">Close</button>
</div>
</dialog>
</ui-dialog>
<script type="module" src="./ui-dialog.js"></script>Includes standalone micro-enhancer and semantic Light-DOM HTML snippet. Open directly in any browser.
# Generates ERB partial, asset pipeline JS, and pins nnuikit in importmap.rb
npx nnuikit add dialog --rails
<%# app/views/pages/home.html.erb %>
<%= render "components/dialog", id: "confirm-modal", title: "Canary Rollout" do %>
<p>Rendered with native Rails ERB and Light-DOM web components.</p>
<% end %>Creates app/views/components/_dialog.html.erb with local_assigns and block yields, and configures Rails Importmaps automatically.
NNUI-KIT provides standalone, W3C DTCG-compliant global CSS theme files. You can import them directly from the package, or copy-paste them straight into your product's globals.css or theme.css:
// Option 1: Full Universal Stylesheet (Cascade layers, tokens, reset & base primitives)
import 'nnuikit/globals.css';
// Option 2: Pure Theme Custom Properties (Zero-dependency CSS variables only)
import 'nnuikit/theme.css';Want to customize brand color harmonies, light/dark modes, and border radii? Visit our Design Tokens & Theme Studio to test components in real time and copy or download your tailored CSS theme file with 1 click.
Crown Innovation: Declarative State Persistence
Zero Router BoilerplateEliminate hundreds of lines of router boilerplate by adding declarative persistence attributes directly to your markup. State automatically hydrates on page load and reflects live changes:
<!-- Automatically binds search, column sort, and pagination to URL query params -->
<ui-data-grid persist="url"></ui-data-grid>
<!-- Autosaves multi-step wizard step and form values to localStorage -->
<ui-stepper persist="local"></ui-stepper>
<!-- Saves unfinished user drafts in AI prompt box -->
<ui-ai-prompt-box persist="local"></ui-ai-prompt-box>Cross-Tab Broadcast Synchronization
Zero Server / Zero WebSocketsEvery NNUI-KIT micro-enhancer supports zero-config multi-tab synchronization powered by the native browser BroadcastChannel API. State updates in one tab instantly propagate to other open tabs:
<!-- Stepper synchronizes current active step across all open browser windows -->
<ui-stepper sync="cross-tab">
<div data-part="step" data-title="Account">...</div>
<div data-part="step" data-title="Profile">...</div>
<div data-part="step" data-title="Review">...</div>
</ui-stepper>
<!-- Combine URL persistence and Cross-Tab sync simultaneously -->
<ui-data-grid persist="url" sync="cross-tab"></ui-data-grid>AI Machine-Readable Introspection Protocol
nnui.ai.v1Every micro-enhancer implements the nnui.ai.v1 introspection protocol. Autonomous AI agents (Cursor, Claude, Copilot, Antigravity) and developer tooling can query live element state and request copy-ready framework snippets at runtime:
const element = document.querySelector('ui-data-grid');
const schema = await element.inspectAI();
console.log(schema.protocol); // "nnui.ai.v1"
console.log(schema.schema.parts); // ["toolbar", "search", "export-btn", "table", "pagination"]
console.log(schema.liveState); // Active rows, sort column, search query
console.log(schema.frameworkSnippets); // Idiomatic React 19, Vue 3, Svelte 5 snippetsCopy the standardized specification so your AI assistant writes 100% accurate NNUI-KIT code without hallucinations.
React 18 & 19 (Next.js 15 App Router)
First-Class Typed WrappersNNUI-KIT provides official React 18 & 19 bindings exported from nnuikit/react. Built with forward-ref semantics, TypeScript interfaces, and Next.js 15 App Router SSR safety:
- Automatic Canvas & Body Theming:
nnuikit/cssautomatically bindshtml, bodyto the canvas background (--ui-bg-canvas) and text colors. You do not need to write manualbody { background-color: ... }rules. - Avoid
* { padding: 0 }: Unlayered universal resets override CSS Cascade Layers and strip internal paddings from buttons, tabs, and accordions. Use standard modern box-sizing:*, *::before, *::after { box-sizing: border-box; } body { margin: 0; }. - Flexbox Column Button Alignment: Flex containers with
flex-direction: columndefault toalign-items: stretch. Wrap action buttons in an action row (e.g.<div style={{ display: 'flex', gap: '0.75rem' }}>) or usealign-self: flex-startso buttons stay at their natural width.
Svelte 5 (Runes Architecture)
Zero Runtime OverheadBecause Svelte compiles directly to native DOM operations without a virtual DOM overhead, NNUI-KIT's Light-DOM architecture integrates natively with Svelte 5 Runes ($state, $derived, $effect):
Vue 3 & Nuxt 3 (Composition API)
Custom Element NativeConfigure your Vite or Nuxt 3 config to treat ui-* and nnui-* tags as custom elements, then use them directly in Vue templates with<script setup>:
HTMX 2 & Backend SSR
Django · Rails · Laravel · GoShadow-DOM libraries fail catastrophically with HTMX because HTML fragment swaps destroy sealed shadow boundaries. NNUI-KIT's pure Light-DOM architecture automatically re-initializes swapped nodes and participates in native <form> submissions via ElementInternals:
Typography System
Open Interactive Studio ↗Proportional type scale with optical letter-spacing, fluid font hierarchies, and standardized semantic text roles. Zero Shadow DOM barriers, rendering instantly with pure semantic HTML:
Lead Paragraph: High visual hierarchy introduction text for hero sections.
Body Paragraph: Standard content typography optimized for sustained reading comprehension.
Muted Text: Secondary metadata, timestamps, and contextual captions.
Layout & Status Primitives
Zero-JS structural primitives that establish clean visual hierarchy across applications:
data-ui="empty" zero-data feedback