# Astralis UI: full documentation React 19 component library on semantic design tokens. Server-first: static components are true Server Components that ship zero client JavaScript (enforced by a build gate, labeled per component in system-spec.json's client field). Precompiled, prefix-isolated CSS (value props deliver through CSS custom properties); no build tooling required in the consuming app. --- # Installation Install the package, import one stylesheet, wrap your app. That's the whole setup. ## Requirements | | | | --- | --- | | React | `^19.1` (with `react-dom`) | | Build tooling | None: no plugins, no preprocessors, no theme compiler | Astralis ships **precompiled CSS**: every class any component can emit is already in the stylesheet, generated and verified at the library's own build time. Your bundler just serves a `.css` file. ## The short way The [CLI](/docs/cli) does all three steps below for you. For a new project: ```bash npx astralis-cli create my-app ``` It runs the official `create-next-app` or `create-vite` prompts, then wires Astralis into the result: stylesheet imported, provider mounted, ready to run. For a project you already have: ```bash npx astralis-cli init ``` Same edits, made in place. Pass `--dry-run` to see them first. If you'd rather do it by hand, or the CLI doesn't recognise your setup, the three steps are below. That's all `init` is doing. ## 1. Install the package ```bash pnpm add astralis-ui # or: npm install astralis-ui / yarn add astralis-ui ``` ## 2. Import the stylesheet (once) ```tsx import "astralis-ui/styles.css"; ``` Do this at your app's entry point (root layout in Next.js, `main.tsx` in Vite). One import covers every component, both themes and all responsive variants. ## 3. Wrap your app in the provider ```tsx import { AstralisProvider } from "astralis-ui"; export function App({ children }) { return {children}; } ``` `AstralisProvider` owns theming: it resolves light/dark (including the `"system"` preference), persists the user's choice to `localStorage`, and, if you pass a brand color, derives the full shade scale at runtime. Details on the [Theming](/docs/theming) page. ## Next.js (App Router) Import the stylesheet and mount the provider in your root layout. The provider is a client component, but your pages stay server components: children pass straight through. ```tsx // app/layout.tsx import { AstralisProvider } from "astralis-ui"; import "astralis-ui/styles.css"; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( {children} ); } ``` ### Avoiding the dark-mode flash The provider applies the `.astralis-dark` class after hydration, so a user who prefers dark can see one light-themed frame first. To paint dark from the very first frame, run this tiny inline script before the body renders (it reads the same storage key the provider uses): ```tsx const themeInit = `(function(){try{var t=localStorage.getItem("astralis-ui-theme");var d=t==="dark"||((!t||t==="system")&&window.matchMedia("(prefers-color-scheme: dark)").matches);if(d)document.documentElement.classList.add("astralis-dark");}catch(e){}})();`; // inside , before your app: