Getting started
This guide is the happy path for a Vite + React 19 app: install from npm, import CSS, wrap providers, and render a Button.
Install
pnpm add @var-ui/react @var-ui/core @var-ui/icons typestyles react react-dom react-aria-componentsnpm install @var-ui/react @var-ui/core @var-ui/icons typestyles react react-dom react-aria-componentsyarn add @var-ui/react @var-ui/core @var-ui/icons typestyles react react-dom react-aria-componentsbun add @var-ui/react @var-ui/core @var-ui/icons typestyles react react-dom react-aria-components @var-ui/icons is optional. Without it, pass icons={{}} to IconProvider.
typestyles is a peer dependency of @var-ui/core, @var-ui/react and @var-ui/astro, so the app and every package share one TypeStyles runtime (one class and token registry). You only import it yourself when you write your own recipes.
Import CSS
import '@var-ui/core/styles.css';That file includes every recipe, base HTML styles, and the default theme. Custom createDesignTheme modules and unused-recipe shedding use extract instead — see Installation.
Providers
Mount DesignSystemProvider with applyToDocument and IconProvider at the root:
import { defaultIcons } from '@var-ui/icons';
import { DesignSystemProvider, IconProvider } from '@var-ui/react';
<DesignSystemProvider applyToDocument>
<IconProvider icons={defaultIcons}>{children}</IconProvider>
</DesignSystemProvider>;Without @var-ui/icons, pass icons={{}} to IconProvider.
applyToDocument puts the theme class on html, so the theme reaches every element, including dialogs and popovers.
First component
import { Button } from '@var-ui/react';
<Button>Click me</Button>;Routing
The components that render links — Link, Button and IconButton with href, SideNav.Item, TopNav links, Breadcrumbs, and Toc — are built on React Aria’s Link. Client-side navigation works through React Aria’s RouterProvider, mounted inside your router’s context so it can translate between router hrefs and plain URLs:
import { RouterProvider } from 'react-aria-components';
import { useHref, useNavigate } from 'react-router-dom';
import { DesignSystemProvider } from '@var-ui/react';
function App() {
return (
<DesignSystemProvider applyToDocument>
<RouterProvider navigate={useNavigate()} useHref={useHref}>
<Routes />
</RouterProvider>
</DesignSystemProvider>
);
}Every link component above then navigates in-app — SideNav.Item href="/settings" pushes the route instead of reloading the page.
Without a RouterProvider, href falls back to normal browser navigation.
Other routers
TanStack Router:
import { RouterProvider } from 'react-aria-components';
import { useRouter } from '@tanstack/react-router';
const router = useRouter();
<RouterProvider
navigate={(href) => router.navigate({ to: href })}
useHref={(href) => router.buildLocation({ to: href }).href}
>
{children}
</RouterProvider>;Next.js App Router (in a client component; href is already the final URL):
'use client';
import { RouterProvider } from 'react-aria-components';
import { useRouter } from 'next/navigation';
const router = useRouter();
<RouterProvider navigate={(href) => router.push(href)} useHref={(href) => href}>
{children}
</RouterProvider>;Caveats:
Cardwithhrefrenders a plain<a>, so it always does a full page navigation. Put aLinkinside the card title when the card should participate in client-side routing.RouterProvideronly intercepts React Aria links; native<a>elements you render yourself are untouched.
Astro without React
pnpm add @var-ui/astro @var-ui/core @var-ui/icons typestylesnpm install @var-ui/astro @var-ui/core @var-ui/icons typestylesyarn add @var-ui/astro @var-ui/core @var-ui/icons typestylesbun add @var-ui/astro @var-ui/core @var-ui/icons typestyles Import the same stylesheet in a layout, then import Astro components:
---
import '@var-ui/core/styles.css';
import { Button } from '@var-ui/astro';
---
<Button>Click me</Button>See examples/astro-app in the repo for a full workspace tree. That example still extracts CSS with the TypeStyles Vite plugin because it lives in this monorepo.
Next
- Installation — package list, peers, and TypeStyles extract for custom themes
- Overlay lifecycle — how native dialogs and popovers open and close, their attributes, and
onOpenChangereasons - Theming — tokens, themes, and
createDesignTheme
Direction and overlays
Direction and locale
Pass direction and a real locale on DesignSystemProvider:
<DesignSystemProvider applyToDocument direction="rtl" locale="he-IL">
{children}
</DesignSystemProvider>applyToDocument syncs html dir (and lang when locale is set) after hydration / on mount. It always writes dir for the resolved direction — including default ltr. If SSR set <html dir="rtl"> and the client provider omits direction/locale, mount will rewrite dir to ltr. SSR apps that care about first paint should set <html dir> (and lang if needed) themselves and pass matching direction/locale to the provider.
Anchored popups (Popover, Menu, Tooltip, and the field popups) place start and end with CSS logical values. They follow the document dir that direction writes — applyToDocument sets it on html. locale formats dates and numbers and configures React Aria; it does not choose the popup side. I18nProvider only accepts locale.
- Prefer a real RTL locale (
he-IL,ar-EG) withdirection="rtl"so formatting and popup sides agree. direction="rtl"with no locale wrapsI18nProviderwitharso React Aria formatting matches the direction. That fallback does not sethtml lang="ar". Popup sides still followdir.direction="ltr"(explicit) with no locale wrapsI18nProviderwithen-USso a nested LTR island does not inherit a parent RTL locale.locale="en-US"plusdirection="rtl"keeps English formatting. Popupstart/endstill followdir.- If you omit
directionbut passlocale,diris derived from RACisRTL(locale), and popups follow thatdir. useDirection()returns{ direction, isRtl }and defaults toltrwhen no provider is mounted.- Directional icons opt in:
<Icon name="chevronRight" data-mirror={isRtl || undefined} />.
Do not set dir on the whole docs site to try this — use a DirectionProvider island (see Hidden).
Overlays and stacking
Dialogs, drawers, popovers, menus, tooltips and toasts are native <dialog> and [popover] elements in the browser top layer. They need no portal, no provider and no z-index, and they always paint above the page. The top layer orders overlays by when they opened, so the most recently opened one is on top.
Because they render in place, a theme class on any ancestor reaches them, and CSS custom properties inherit as usual. There is no portalContainer to set. The flip side is that a <button> inside a dialog inside a <form> submits that form (give it type="button"), and DOM events bubble through the dialog’s real ancestors; see Plain CSS.
How overlays open and close, their state attributes, and the onOpenChange reasons are documented in Overlay lifecycle.