Quick Start
Install PeakUI, import its styles in the right order and render your first component.
Requirements
- React 19 or later
- Tailwind CSS v4
Install
Install the two PeakUI packages:
npm install @peakui/react @peakui/stylesnpm (7 or later), pnpm (8 or later) and Bun install peer dependencies automatically, so the React Aria packages arrive with @peakui/react. With Yarn, add them yourself:
npm install react-aria-components @react-aria/utilsTailwind CSS is a peer dependency of @peakui/styles; if your project does not have it yet, follow the Tailwind CSS installation guide for your framework first.
Import Styles
Add both imports to your main CSS file, for example app/globals.css:
@import "tailwindcss";
@import "@peakui/styles";In CSS files the bare package name resolves to the stylesheet through the style export condition, which Tailwind, Vite and Next.js follow. The explicit subpath @peakui/styles/css is the same file, for tooling that does not follow the condition.
The order matters. @peakui/styles extends Tailwind and does not import it. If Tailwind comes second, or is missing, the component styles are silently absent: there is no build error.
Use Components
Import components from the package root:
import {Button, Input, Label, TextField} from "@peakui/react";
export function SignUp() {
return (
<form className="flex w-64 flex-col gap-3">
<TextField isRequired name="email" type="email">
<Label>Email</Label>
<Input placeholder="jane@example.com" />
</TextField>
<Button type="submit">Sign up</Button>
</form>
);
}There is no provider to add. The theme lives in CSS.
Server Components
Every PeakUI component is a client component, marked with "use client". You can render one from a server component, but you cannot pass it a function from there: React cannot send a function from the server to the client. Props such as onPress, a className function or children written as a render function need a file that itself starts with "use client". In Next.js, put the component and its event handler together in a client file, and import that file from the server component:
"use client";
import {Button} from "@peakui/react";
export function SaveButton({id}: {id: string}) {
return <Button onPress={() => fetch(`/api/items/${id}`, {method: "POST"})}>Save</Button>;
}The directive matters only with React Server Components. In a client-only app, such as one built with Vite, the examples work without it: it has no effect there, and Vite's production build prints a warning that it was ignored.
Tailwind class detection
Tailwind finds class names by scanning your source files as text. Two consequences:
- Write class names in full.
className={isActive ? "bg-accent" : "bg-default"}works; a name assembled by interpolation, such as`bg-${role}`, never reaches the CSS. - Files outside your app's own sources are not scanned. Utility classes that come from another package in
node_modulesstay out of the CSS until you point Tailwind at that package with@sourcein your CSS entry. The path is relative to the CSS file:
@import "tailwindcss";
@import "@peakui/styles";
@source "../node_modules/@acme/ui";- To keep specific classes that never appear as whole strings in any scanned file, list them with
@source inline("bg-accent text-sm"). - Tailwind v4 does not read
tailwind.config.jsortailwind.config.tsby itself. Acontentlist in it is ignored unless the CSS loads the file with@config "./tailwind.config.ts";, andsafelistis not supported at all: use@source inline()instead.