React Library • UI State

React Zero UI Core.

Update your UI without re-rendering React components. Core has built-in global state management and generates Tailwind variants you can use across your app.

Global and scoped UI state.

A state change can affect the whole page or just one part of it.

Page-wide settings

The useUI hook sets a data attribute on the page body. Nested components can respond to that state through CSS without passing it through props.

Independent controls

With useScopedUI, each tab group on this site keeps its own selection. Changing tabs updates a CSS variable on that group.

CSS variables

Either hook can update a CSS custom property for values such as a color or blur radius.

How useUI works.

The useUI hook follows the same pattern as React’s useState. In the diagram, useUI("theme", "light") returns the initial value and a setter named setTheme.

Core detects the hook call at build time and automatically generates the matching Tailwind variants. Add theme-dark:bg-black to any element in your app. Calling setTheme("dark") gives each element with that class a black background.

Set up Core.

Use @react-zero-ui/core with Tailwind CSS v4 in a Vite or Next.js App Router project.

  1. Install Core.

    Run npx create-zero-ui from your project root, or follow the guide for your framework.

  2. Define a UI state.

    Call useUI in a component with a state name and an initial value.

  3. Connect it to your UI.

    Style each state with its generated Tailwind variant. Call the hook’s setter to switch between states.