# All Components > Every component available in PeakUI, grouped by purpose. **Category**: components **URL**: https://peakui.dev/en/docs/react/components **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/components/index.mdx ## Buttons - [Button](https://peakui.dev/en/docs/react/components/button): A pressable button with seven visual variants, three sizes, and disabled and pending states. - [ButtonGroup](https://peakui.dev/en/docs/react/components/button-group): Groups related buttons into one connected control - [CloseButton](https://peakui.dev/en/docs/react/components/close-button): An icon-only dismiss control with a built-in glyph and label - [SegmentedControl](https://peakui.dev/en/docs/react/components/segmented-control): Picks one option from a small set, with an indicator that slides to the chosen segment - [ToggleButton](https://peakui.dev/en/docs/react/components/toggle-button): A two-state button for on/off and selected states - [ToggleButtonGroup](https://peakui.dev/en/docs/react/components/toggle-button-group): Groups toggle buttons for single or multiple selection ## Collections - [ContextMenu](https://peakui.dev/en/docs/react/components/context-menu): Menu opened by right-click, long-press or keyboard - [Dropdown](https://peakui.dev/en/docs/react/components/dropdown): Dropdown menu triggered by a button - [ListBox](https://peakui.dev/en/docs/react/components/list-box): A listbox displays selectable options - [Menu](https://peakui.dev/en/docs/react/components/menu): Inline menu that is always visible - [TagGroup](https://peakui.dev/en/docs/react/components/tag-group): A focusable list of selectable and removable tags ## Controls - [Slider](https://peakui.dev/en/docs/react/components/slider): Selects one or more values within a range ## Data Display - [Badge](https://peakui.dev/en/docs/react/components/badge): A small indicator anchored over another element, such as a count or a status dot - [Chip](https://peakui.dev/en/docs/react/components/chip): A compact label for statuses, filters and attributes ## Feedback - [Alert](https://peakui.dev/en/docs/react/components/alert): A status message with an icon, title and description - [EmptyState](https://peakui.dev/en/docs/react/components/empty-state): A placeholder for content with nothing to show - [Meter](https://peakui.dev/en/docs/react/components/meter): Shows a quantity within a known range, such as disk usage - [ProgressBar](https://peakui.dev/en/docs/react/components/progress-bar): Shows determinate or indeterminate progress of an operation - [ProgressCircle](https://peakui.dev/en/docs/react/components/progress-circle): A circular indicator for determinate or indeterminate progress - [Skeleton](https://peakui.dev/en/docs/react/components/skeleton): A placeholder showing the shape of content that is still loading - [Spinner](https://peakui.dev/en/docs/react/components/spinner): A loading indicator in four sizes and five colors, announced to assistive technology as a status. ## Forms - [Checkbox](https://peakui.dev/en/docs/react/components/checkbox): Selectable box with label and indicator - [CheckboxGroup](https://peakui.dev/en/docs/react/components/checkbox-group): Group of related checkboxes - [Description](https://peakui.dev/en/docs/react/components/description): Helper text for a form field, linked to the control so assistive technology reads it with the label. - [ErrorMessage](https://peakui.dev/en/docs/react/components/error-message): Error text displayed through a parent's error slot - [FieldError](https://peakui.dev/en/docs/react/components/field-error): A validation message for a form field, rendered only while the field is invalid. - [Fieldset](https://peakui.dev/en/docs/react/components/fieldset): Groups related form fields under a legend, with a slot for the actions that belong to them. - [Form](https://peakui.dev/en/docs/react/components/form): Validation-aware form wrapper - [Input](https://peakui.dev/en/docs/react/components/input): A single-line text input, used on its own or as the control inside a TextField. - [InputGroup](https://peakui.dev/en/docs/react/components/input-group): An input or a text area with a prefix and a suffix inside one shared frame. - [InputOtp](https://peakui.dev/en/docs/react/components/input-otp): One-time password input for verification codes - [Label](https://peakui.dev/en/docs/react/components/label): A text label for a form control, with required, invalid and disabled states. - [NumberField](https://peakui.dev/en/docs/react/components/number-field): Numeric input with stepper buttons - [RadioGroup](https://peakui.dev/en/docs/react/components/radio-group): Mutually exclusive radio buttons - [SearchField](https://peakui.dev/en/docs/react/components/search-field): Search input with icon and clear button - [Switch](https://peakui.dev/en/docs/react/components/switch): On and off toggle control - [TextField](https://peakui.dev/en/docs/react/components/text-field): A text input with a label, a description and validation, composed from separate parts. - [TextArea](https://peakui.dev/en/docs/react/components/textarea): Multiline text input ## Layout - [Card](https://peakui.dev/en/docs/react/components/card): A content container with header, body and footer - [Separator](https://peakui.dev/en/docs/react/components/separator): Visually divide content sections - [Surface](https://peakui.dev/en/docs/react/components/surface): A themed surface level for content and nested controls - [Toolbar](https://peakui.dev/en/docs/react/components/toolbar): Groups controls with arrow key navigation ## Navigation - [Accordion](https://peakui.dev/en/docs/react/components/accordion): Vertically stacked expandable sections - [Breadcrumbs](https://peakui.dev/en/docs/react/components/breadcrumbs): Breadcrumb trail for hierarchical navigation - [Disclosure](https://peakui.dev/en/docs/react/components/disclosure): A collapsible section with a heading and a trigger - [DisclosureGroup](https://peakui.dev/en/docs/react/components/disclosure-group): Container coordinating multiple expanded disclosures - [Link](https://peakui.dev/en/docs/react/components/link): A styled navigation link with optional icon - [Pagination](https://peakui.dev/en/docs/react/components/pagination): Page navigation with numbered links - [Tabs](https://peakui.dev/en/docs/react/components/tabs): Tabbed sections with a scrolling tab list ## Overlays - [AlertDialog](https://peakui.dev/en/docs/react/components/alert-dialog): Modal dialog that demands an explicit answer - [Drawer](https://peakui.dev/en/docs/react/components/drawer): Edge-docked panel overlay with drag to dismiss - [Modal](https://peakui.dev/en/docs/react/components/modal): Modal dialog overlay for focused interactions - [Popover](https://peakui.dev/en/docs/react/components/popover): Overlay anchored to a trigger - [Sheet](https://peakui.dev/en/docs/react/components/sheet): Sheet component - [Toast](https://peakui.dev/en/docs/react/components/toast): Temporary notifications with auto-dismiss and stacking - [Tooltip](https://peakui.dev/en/docs/react/components/tooltip): Informative text on hover or focus ## Typography - [Kbd](https://peakui.dev/en/docs/react/components/kbd): Display keyboard shortcuts and key combinations - [Typography](https://peakui.dev/en/docs/react/components/typography): Headings, paragraphs and code with the type scale, weights and colors of the design system ## Utilities - [ScrollShadow](https://peakui.dev/en/docs/react/components/scroll-shadow): Shadows that reveal scrollable overflow at container edges # Animation > The easing and animation tokens, and how a component animates a state **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started/animation **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/(handbook)/animation.mdx Motion comes from three places: easing and animation tokens in the theme, the data attributes a component sets as its state changes, and the reduced-motion variant that stands all of it down. It is CSS throughout — the entry and exit utilities come from `tw-animate-css`, which `@peakui/styles` imports for you, and there is no JavaScript motion library. ## Easing Each curve is a custom property and a Tailwind utility of the same name. | Token | Value | Used by | | --------------------- | ---------------------------------------- | ------------------------------------------------------------------------ | | `--ease-out` | `cubic-bezier(0.16, 1, 0.3, 1)` | 46 stylesheets — the default for a transition | | `--ease-smooth` | `ease` | 35 stylesheets — hover, press and focus changes | | `--ease-out-quart` | `cubic-bezier(0.165, 0.84, 0.44, 1)` | Modal, Drawer, AlertDialog, Dropdown, MenuItem, ListBoxItem, CloseButton | | `--ease-out-fluid` | `cubic-bezier(0.32, 0.72, 0, 1)` | SegmentedControl, Switch, Tabs, Toast — a part that slides into place | | `--ease-out-quad` | `cubic-bezier(0.25, 0.46, 0.45, 0.94)` | Accordion and Disclosure, opening and closing | | `--ease-linear` | `linear` | Checkbox, for the icon's scale and opacity | | `--ease-in-out-cubic` | `cubic-bezier(0.645, 0.045, 0.355, 1)` | Your own CSS: the library uses it nowhere | | `--ease-in-cubic` | `cubic-bezier(0.55, 0.055, 0.675, 0.19)` | Your own CSS: the library uses it nowhere | ```css .my-panel { transition: transform 150ms var(--ease-out); } ``` ```tsx
``` ## Looping Animations Three compositions, each a `@keyframes` and its timing. The `skeleton` and `caret-blink` keyframes are declared in the theme beside them; `spin` is Tailwind's own. | Token | Value | Utility | Used by | | ----------------------- | ------------------------------------ | --------------------- | -------- | | `--animate-spin-fast` | `spin 0.75s linear infinite` | `animate-spin-fast` | Spinner | | `--animate-skeleton` | `skeleton 2s linear infinite` | `animate-skeleton` | Skeleton | | `--animate-caret-blink` | `caret-blink 1.2s ease-out infinite` | `animate-caret-blink` | InputOTP | ## Animating a State A component writes its state onto the DOM as `data-*` attributes, and CSS selects on them. Thirteen component stylesheets animate entry and exit this way, overlays among them. ```css /* The attribute carries a value: match `="true"`, not the bare attribute. */ .my-popover[data-entering="true"] { opacity: 1; transform: scale(1); transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out); } .my-popover[data-exiting="true"] { opacity: 0; } ``` `data-placement` carries the side an overlay opened on, which is what lets one rule slide a popover in from the direction it came from. Each component page lists the attributes it sets. The library's own overlays write these phases with the `tw-animate-css` utilities rather than by hand — `animate-in`, `animate-out`, `fade-in-0`, `zoom-in-90`, `slide-in-from-bottom-1` — and they are available to you on the same attributes. ## Reduced Motion Every animated stylesheet in the library stands down when the reader asks for less motion, through the `motion-reduce` variant. Write the same into any animation of your own. ```tsx
``` ```css .my-panel { @media (prefers-reduced-motion: reduce) { transition: none; } } ``` One component does not need it: `ScrollShadow` interpolates its fades along the scroll position rather than along time, so there is no motion of its own to stop. ## Using a Motion Library There is no JavaScript motion library here, and a component that renders a plain DOM element does not need one to be replaced: it takes a `render` prop, so an element from a motion library can take its place. Which components accept it, and the React Aria restriction that decides it, are in [Composition](https://peakui.dev/en/docs/react/getting-started/composition). # Colors > Every color role in the theme, with the token and the utility that reach it **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started/colors **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/(handbook)/colors.mdx Colors are semantic: a component asks for a role, never for a value. Every role that carries content has a `-foreground` partner readable on it, and the two move together when a theme changes one. Each role below is shown in both shipped themes at once, drawn from the tokens themselves. A variant is drawn **inside** the layer it appears on, because that is where it appears: a hover replaces the surface under it, a foreground is content on that surface, and a tint is stacked on whatever it tints. The name on a layer is written in the foreground it pairs with, so the label is the legibility test. ## Accent The primary action, used sparingly: overuse costs it its meaning. A `-soft` role is the same hue at low opacity, so what shows through it belongs to the layer underneath. ## Default The neutral control: every button, chip and toggle that carries no status. ## Success ## Warning ## Danger ## Text Text roles are drawn on the page itself. `--muted` is secondary text, not disabled text: a disabled control carries `--disabled-opacity`. ## Backgrounds The deeper levels exist for regions inside regions, which is how they are drawn here. ## Surfaces A surface is a container that does not float: a card, a panel, a table header. Its levels nest the same way the backgrounds do. ## On Surface Controls that sit on a surface rather than on the page, so they stay distinct from it. ## Overlays A floating container — popover, menu, tooltip — and the scrim behind a modal one. `--backdrop` is translucent, so what you see through it is the page underneath. ## Form Fields A field carries its own roles, because it reads as an input whatever surface holds it. The border belongs to the field, so it is drawn inside it — and `--field-border` is transparent in both themes: the field is told apart by its background, and the outline appears on hover and focus. ## Borders and Separators A border outlines a thing; a separator divides two. Each has two quieter levels. ## Focus and Chrome The thumb rides the track, so it is drawn on it. ## Primitives Two values are absolute rather than semantic — `--black` and `--white`. They do not change with the theme, which is the only reason to reach for one. ## Using a Role Every role is a Tailwind utility and a custom property at once. Reach for the utility in markup and the property in CSS of your own. ```tsx
Secondary
``` ```css .my-panel { background-color: var(--surface); color: var(--surface-foreground); } ``` Take the pair, not one half of it: `bg-surface` with `text-foreground` survives the default theme and breaks in the next one. ## Changing a Role Override the property and every component that asks for the role follows — the mechanics, the levels at which an override lands and the dark-theme pair are in [Theming](https://peakui.dev/en/docs/react/getting-started/theming). To try values against a whole page first, use the [Theme Builder](https://peakui.dev/themes), which exports the CSS it shows.
# Composition > How PeakUI components are assembled - compound parts, field composition, the render prop and reusing styles on your own elements. **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started/composition **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/(handbook)/composition.mdx PeakUI components are small parts that you compose. The library never assembles them behind a single prop: there is no ``. ## Compound Components A component with several parts exposes them on the root: ```tsx import {Button, Fieldset} from "@peakui/react";
Profile {/* fields */}
``` The same parts are also exported under flat names, which some teams prefer for tree-shaking clarity or code search. All three forms render the same thing: ```tsx import {Fieldset, FieldsetLegend, FieldsetRoot} from "@peakui/react";
…
… … … … ``` ## Fields A text field is a root with sibling parts. `TextField` owns the value, the validation state and the ids that link the parts together: ```tsx import {Description, FieldError, Input, Label, TextField} from "@peakui/react"; We never share your email. ``` - `Label`, `Description` and `FieldError` are connected to the input through `aria-labelledby` and `aria-describedby` without any ids from you. - Outside a field the two differ. `Description` still renders its ``, but nothing links it to a control. `FieldError` renders nothing: it needs the field's validation state, and it also renders nothing while the field is valid. - `variant` on `TextField` flows down to `Input` and `InputGroup`. A nested field resets it rather than inheriting. Swap `Input` for `InputGroup` when the control needs a prefix or a suffix: ```tsx https:// ``` ## React Aria Props Interaction props follow React Aria's names, not the DOM's: | Use | Instead of | | --------------------------------------- | -------------------------------------- | | `onPress` | `onClick` | | `isDisabled` | `disabled` | | `isPending` | a `loading` prop | | `isRequired`, `isInvalid`, `isReadOnly` | `required`, `aria-invalid`, `readOnly` | Two exceptions follow the DOM because they render a native element with no React Aria state of their own: a standalone `Input` takes `disabled`, and `Fieldset` takes `disabled`. A pending button does not show a spinner by itself. Put one in its children: ```tsx import {Button, Spinner} from "@peakui/react"; ``` ## Custom DOM Element There is no `as` prop. Components that render a plain DOM element accept `render`, a function that receives the props the part would have applied and returns your element: ```tsx
}> {/* fields */} ``` Spread `props` onto the element you return: it carries the class, the `data-slot` and the ref. Components built on a React Aria primitive, such as `Button`, take the same prop with one restriction from React Aria: the function must return the element type the component expects. A `Button` must still render a ` ); } ``` ## Without a library Set the attribute yourself. This follows the system preference: ```tsx "use client"; import {useEffect} from "react"; export function useSystemTheme() { useEffect(() => { const media = window.matchMedia("(prefers-color-scheme: dark)"); const apply = () => { document.documentElement.dataset.theme = media.matches ? "default-dark" : "default-light"; }; apply(); media.addEventListener("change", apply); return () => media.removeEventListener("change", apply); }, []); } ``` ## The `dark:` variant Tailwind's `dark:` variant follows `prefers-color-scheme` unless you redefine it. To make it follow the PeakUI theme, declare it once in your CSS: ```css title="globals.css" @import "tailwindcss"; @import "@peakui/styles"; @custom-variant dark (&:where(.default-dark, .default-dark *, [data-theme="default-dark"], [data-theme="default-dark"] *)); ``` ## Styling for both themes You rarely need `dark:` at all. The semantic tokens change with the theme, so one class covers both: ```tsx

This text is readable in both themes.

``` # Styling > The ways to restyle a PeakUI component - class names, state selectors, BEM classes, component variables and variant functions. **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started/styling **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/(handbook)/styling.mdx PeakUI components are styled by plain CSS classes. Nothing is generated at runtime, so every technique you already use with CSS and Tailwind works. ## Basic Styling Pass `className` to any component or part. Your classes are merged with the component's own: ```tsx import {Button} from "@peakui/react"; ``` `style` works as usual: ```tsx ``` There is no `classNames` prop. To style a part, pass `className` to that part: ```tsx
Profile
``` ## State-Based Styling Components expose their state as data attributes, which you can target from Tailwind or CSS: ```tsx ``` ```css .button[data-pressed] { transform: scale(0.97); } ``` `@peakui/styles` also registers short variants for the most common states: | Variant | Matches | | ----------------------- | ---------------------- | | `hovered:` | `[data-hovered]` | | `pressed:` | `[data-pressed]` | | `focus-visible-within:` | `[data-focus-visible]` | | `selected:` | `[data-selected]` | | `disabled-state:` | `[data-disabled]` | | `entering:` | `[data-entering]` | | `exiting:` | `[data-exiting]` | ```tsx ``` ## Render Props For components built on a React Aria primitive, `className` and `children` also accept a function that receives the component's state: ```tsx "use client"; import {Button} from "@peakui/react"; ``` A function prop needs a client component: a server component cannot pass a function to `Button`. ## BEM Classes Every component is a [BEM](https://getbem.com/) block. Variants are modifiers and parts are elements: ```css .button /* block */ .button--primary /* modifier: variant */ .button--sm /* modifier: size */ .fieldset__legend /* element: a part */ ``` Override them in the `components` layer, after the PeakUI import: ```css title="globals.css" @import "tailwindcss"; @import "@peakui/styles"; @layer components { .button { @apply font-semibold tracking-wide; } .button--sm { @apply px-2; } } ``` ## Component Variables Where a component's colors or radius are meant to change, it reads them from its own custom properties. Setting the variable is safer than overriding the declaration, because hover, pressed and focus styles keep working: ```css @layer components { .button--secondary { --button-bg: var(--color-surface); --button-bg-hover: var(--color-surface-hover); --button-fg: var(--color-surface-foreground); } } ``` ## Slots Every rendered element carries a `data-slot` attribute naming the part. It is a stable hook for styling a part from its parent: ```css .my-form [data-slot="label"] { @apply text-xs tracking-wide uppercase; } ``` ## Variant Functions Each component's class names come from a variant function exported next to it, such as `buttonVariants`. Calling it returns the class string: ```tsx import {buttonVariants} from "@peakui/react"; buttonVariants({size: "sm", variant: "outline"}); // "button button--sm button--outline" ``` Use it to give another element the look of a component: ```tsx See pricing ``` ## Adding Variants Describe the variants of your own with `tv`, imported from `@peakui/react`, and let `Button` keep `size` and `variant`: ```tsx import type {ButtonProps, VariantProps} from "@peakui/react"; import {Button, tv} from "@peakui/react"; const myButtonVariants = tv({ variants: { radius: { full: "rounded-full", sm: "rounded-sm", }, }, }); interface MyButtonProps extends Omit, VariantProps { className?: string; } export function MyButton({className, radius, ...props}: MyButtonProps) { return ``` | Variant | Purpose | Usage | | ----------- | ------------------------------------------- | --------------- | | `primary` | The main action that moves the task forward | One per context | | `secondary` | Alternative actions | Several allowed | | `tertiary` | Dismissive actions such as cancel or skip | Sparingly | | `danger` | Destructive actions | When needed | `Button` also has `outline`, `ghost` and `danger-soft` for lower-emphasis placements. ### 2. Accessibility as Foundation Behavior comes from [React Aria Components](https://react-aria.adobe.com/): ARIA attributes, keyboard interaction and focus management are built in. The floor is WCAG 2.2 AA, including `forced-colors` mode. ```tsx import {Tabs} from "@peakui/react"; Profile Security Profile settings Security settings ``` ### 3. Composition Over Configuration A component is a root plus named parts. Rearrange them, restyle one, or leave one out: the library never assembles them behind a single prop. ```tsx import {Disclosure} from "@peakui/react"; Shipping details Orders ship within two business days. ``` See [Composition](https://peakui.dev/docs/react/getting-started/composition) for fields, the `render` prop and custom components. ### 4. Progressive Disclosure A component works with no props. Add them only as the requirement grows: ```tsx import {Check} from "@gravity-ui/icons"; import {Button, Spinner} from "@peakui/react"; // Level 1: minimal // Level 2: variant, size and an icon // Level 3: pending state ``` ### 5. Predictable Behavior The same prop means the same thing on every component: `size`, `variant` and `className`, with state exposed as `data-*` attributes. ```tsx import {Button, Chip, Spinner} from "@peakui/react"; Pending ``` Every part of a compound component is available in dot notation and as a named export: ```tsx import {Alert, AlertIndicator} from "@peakui/react"; // Dot notation // Named export ``` ### 6. Type Safety First Props, variants and event handlers are typed, and every component exports its props type for you to extend. ```tsx import type {ButtonProps} from "@peakui/react"; import {Button} from "@peakui/react"; // Extend the props type for your own component interface IntentButtonProps extends Omit { intent: "save" | "cancel" | "delete"; } ``` ### 7. Separation of Styles and Logic `@peakui/styles` holds the CSS and the variant functions and has no React dependency; `@peakui/react` adds the behavior. The classes work in any framework and in plain HTML: ```html ``` In React, the variant function returns the same class string: ```tsx import {buttonVariants} from "@peakui/styles"; Home ``` ### 8. Developer Experience Excellence One import root, typed APIs, and documentation an AI assistant can read: every page has a markdown version listed in [`/llms.txt`](https://peakui.dev/docs/react/getting-started/llms-txt), and the [`peakui-react` skill](https://peakui.dev/docs/react/getting-started/agent-skills) teaches a coding agent the conventions. ```tsx import {Button, Tabs, TextField} from "@peakui/react"; ``` ### 9. Complete Customization Change the whole theme with CSS variables, or one component through its BEM classes and its own variables. ```css title="globals.css" /* Theme-wide: every component follows */ :root { --accent: oklch(0.6 0.2 250); --radius: 0.75rem; } /* One component */ @layer components { .button { @apply font-semibold tracking-wide; } .button--secondary { --button-bg: var(--color-surface); --button-fg: var(--color-surface-foreground); } } ``` See [Theming](https://peakui.dev/docs/react/getting-started/theming) for the tokens and [Styling](https://peakui.dev/docs/react/getting-started/styling) for classes, slots and state selectors. ### 10. Open and Extensible Wrap, extend and restyle components to fit your product. Four techniques cover most cases. **Apply styles with a variant function:** ```tsx import {Link, linkVariants} from "@peakui/react"; import NextLink from "next/link"; const slots = linkVariants(); About ``` **Apply BEM classes directly:** ```tsx import Link from "next/link"; Dashboard ``` **Create a wrapper component:** ```tsx import type {ButtonProps} from "@peakui/react"; import {Button} from "@peakui/react"; interface CTAButtonProps extends Omit { intent?: "primary-cta" | "secondary-cta" | "minimal"; } const variantByIntent = { minimal: "ghost", "primary-cta": "primary", "secondary-cta": "secondary", } as const; export function CTAButton({intent = "primary-cta", ...props}: CTAButtonProps) { return ); } ``` 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: ```tsx title="save-button.tsx" "use client"; import {Button} from "@peakui/react"; export function SaveButton({id}: {id: string}) { return ; } ``` 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_modules` stay out of the CSS until you point Tailwind at that package with [`@source`](https://tailwindcss.com/docs/detecting-classes-in-source-files) in your CSS entry. The path is relative to the CSS file: ```css title="globals.css" @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.js` or `tailwind.config.ts` by itself. A `content` list in it is ignored unless the CSS loads the file with `@config "./tailwind.config.ts";`, and `safelist` is not supported at all: use `@source inline()` instead. ## What's Next? - [Browse the components](https://peakui.dev/docs/react/components) - [Learn how theming works](https://peakui.dev/docs/react/getting-started/theming) - [Set up dark mode](https://peakui.dev/docs/react/getting-started/dark-mode)
# Agent Skills > Install the PeakUI skill so your AI coding agent writes correct PeakUI code. **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started/agent-skills **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/(ui-for-agents)/agent-skills.mdx The `peakui-react` skill teaches a coding agent how PeakUI components are composed and styled. For each component it uses, the agent reads the documentation page from this site. ## Install ```bash npx skills add peakui-dev/peakui --skill peakui-react ``` The skill is copied to `.agents/skills/peakui-react/` and linked from `.claude/skills/peakui-react/`, the two folders coding agents read skills from. ## Point Your Agent at It Agents do not always load an installed skill on their own. Paste this block into `AGENTS.md` and `CLAUDE.md` at the root of your project: ```md This project uses PeakUI (`@peakui/react`, `@peakui/styles`). Before writing or changing UI code, load the `peakui-react` skill and follow it. Without skills: read https://peakui.dev/llms.txt first. ``` ## Update ```bash npx skills update ``` ## What the Scripts Access The skill ships two scripts that the agent runs with Node.js 18 or later. | Script | Reads | Network | | -------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | | `scripts/docs.mjs` | The documentation index and the pages the agent asks for; with `--source`, a component's source file | `GET` requests to this site and, for `--source`, to `raw.githubusercontent.com` | | `scripts/doctor.mjs` | Your project's `package.json`, installed package versions and CSS imports | None | Neither script writes a file or sends anything about your project. ## Mirrors and Previews Set `PEAKUI_DOCS_URL` to read the documentation from another origin: ```bash PEAKUI_DOCS_URL=https://docs.internal.example node .agents/skills/peakui-react/scripts/docs.mjs list ``` # LLMs.txt > Machine-readable versions of the PeakUI documentation for AI coding assistants. **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started/llms-txt **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/(ui-for-agents)/llms-txt.mdx The documentation is published in formats that an AI assistant can read directly. Every file below is generated from the same pages you are reading, so it cannot drift from them. ## Available Files | File | Content | | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`/llms.txt`](https://peakui.dev/llms.txt) | An index: one line per page with its title, URL and description. | | [`/llms-components.txt`](https://peakui.dev/llms-components.txt) | Every component page as markdown, concatenated. | | [`/llms-patterns.txt`](https://peakui.dev/llms-patterns.txt) | Every guide as markdown, concatenated. A guide is any documentation page that is not a component page; the components gallery counts as one. | | [`/api/components`](https://peakui.dev/api/components) | A JSON index of all components and all guides, with a `schemaVersion`: the components (name, title, description, page URL, markdown URL, source and style links), the guides (the same fields without links) and the library version. | ## Per-page Markdown Any documentation page is available as markdown in two ways: - Append `.md` to its URL: `/docs/react/components/button.md`. - Request the page with the header `Accept: text/markdown`. In the markdown, each live example is replaced by the source code of that example. ## Integration Most assistants can be pointed at a documentation URL. **Claude Code** – add to `CLAUDE.md`: ```md PeakUI documentation index: /llms.txt Fetch a component's page as markdown before using it: /docs/react/components/.md ``` **Cursor** – add the `llms.txt` URL under `@Docs`. **Any agent with a fetch tool** – start from `/llms.txt`, then fetch the `.md` version of the pages it lists. # MCP Server > Give your AI assistant direct access to the PeakUI documentation. **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started/mcp-server **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/(ui-for-agents)/mcp-server.mdx The PeakUI MCP server gives an AI coding assistant the component documentation, component stylesheets, theme variables and guides. It is published as `@peakui/mcp`, runs over [stdio](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#stdio) and fetches what it serves on demand, so an answer matches the current documentation. The server holds facts, not rules. The conventions for composing and styling PeakUI live in the [`peakui-react` skill](https://peakui.dev/docs/react/getting-started/agent-skills), which works alongside it. ## Quick Setup Every snippet sets `PEAKUI_DOCS_URL`, the address of the documentation site the server reads. ### Cursor Add the server to `.cursor/mcp.json` in your project, or to `~/.cursor/mcp.json` for every project: ```json title=".cursor/mcp.json" { "mcpServers": { "peakui": { "command": "npx", "args": ["-y", "@peakui/mcp@latest"], "env": { "PEAKUI_DOCS_URL": "https://peakui.dev" } } } } ``` See the [Cursor MCP documentation](https://cursor.com/docs/context/mcp) for more details. ### Claude Code Run this command in your terminal: ```bash claude mcp add peakui -e PEAKUI_DOCS_URL=https://peakui.dev -- npx -y @peakui/mcp@latest ``` Or add the server to your project's `.mcp.json` file: ```json title=".mcp.json" { "mcpServers": { "peakui": { "command": "npx", "args": ["-y", "@peakui/mcp@latest"], "env": { "PEAKUI_DOCS_URL": "https://peakui.dev" } } } } ``` Restart Claude Code and run `/mcp`: the `peakui` server is in the list, marked as connected. See the [Claude Code MCP documentation](https://code.claude.com/docs/en/mcp) for more details. ### Zed Add the server to your `settings.json`: ```json title="settings.json" { "context_servers": { "peakui": { "command": "npx", "args": ["-y", "@peakui/mcp@latest"], "env": { "PEAKUI_DOCS_URL": "https://peakui.dev" } } } } ``` Open **Settings** → **AI** → **MCP Servers**: a green indicator next to the server means it is active. See the [Zed MCP documentation](https://zed.dev/docs/ai/mcp) for more details. ### VS Code Add the server to your project's `.vscode/mcp.json` file: ```json title=".vscode/mcp.json" { "servers": { "peakui": { "type": "stdio", "command": "npx", "args": ["-y", "@peakui/mcp@latest"], "env": { "PEAKUI_DOCS_URL": "https://peakui.dev" } } } } ``` Start the server from the inline action above its entry in `mcp.json`. See the [VS Code MCP documentation](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) for more details. ### Codex Add the server to `~/.codex/config.toml`: ```toml title="config.toml" [mcp_servers.peakui] command = "npx" args = ["-y", "@peakui/mcp@latest"] [mcp_servers.peakui.env] PEAKUI_DOCS_URL = "https://peakui.dev" ``` See the [Codex MCP documentation](https://developers.openai.com/codex/mcp) for more details. ### OpenCode Add the server to your project's `opencode.json` file: ```json title="opencode.json" { "$schema": "https://opencode.ai/config.json", "mcp": { "peakui": { "type": "local", "command": ["npx", "-y", "@peakui/mcp@latest"], "environment": { "PEAKUI_DOCS_URL": "https://peakui.dev" } } } } ``` See the [OpenCode MCP documentation](https://opencode.ai/docs/mcp-servers/) for more details. ### Other Clients Any client that starts a stdio server needs the same three things: the command `npx`, the arguments `-y @peakui/mcp@latest` and the `PEAKUI_DOCS_URL` environment variable. ## Usage Once configured, ask your AI assistant questions like: - "Show me all PeakUI components" - "What props does the Button component have?" - "Give me an example of using the Tabs component" - "Show me the CSS classes and variables of Card" - "What are the theme variables for dark mode?" - "How do I install PeakUI in my app?" ## Available Tools Every tool is read-only. | Tool | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ | | `list_components` | Every PeakUI component with its name and a one-line description | | `get_component_docs` | The documentation page of one to ten components as markdown: usage, examples, styling reference and API reference | | `get_component_styles` | The stylesheet of one to ten components: BEM classes, data attributes and CSS custom properties | | `get_theme_variables` | The default theme: every CSS custom property with its light and dark value | | `get_docs` | A guide as markdown, such as `/docs/react/getting-started/quick-start`, or the list of guides when called without a path | ## Configuration The server is configured with environment variables. | Variable | Meaning | | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | | `PEAKUI_DOCS_URL` | Address of the PeakUI documentation site: an `http` or `https` URL with an optional path, and no query string, fragment or credentials | | `PEAKUI_TELEMETRY_DISABLED` | Set to `1` to disable telemetry | | `DO_NOT_TRACK` | Set to `1` to disable telemetry | No telemetry is sent today. A future release may send the client name and version, the tool name, the names of the components asked for and the server version. Source code, file paths, project names and arguments are never collected. ## Offline Behavior - The server starts without the network and makes no request until a tool is called. - Pages are cached in memory for five minutes. - When the documentation site is unreachable, a cached copy is served with a note saying how old it is. - Styles and theme variables are read from the `@peakui/styles` package installed in your project, and from the repository when it is not installed. ## Troubleshooting **Requirements:** Node.js 20 or later. `npx` downloads the package the first time it runs. **The server does not start:** check `PEAKUI_DOCS_URL`. An invalid address is the one error reported at startup; every other failure comes back from the tool call as a message that says what to check. **Need help?** [GitHub Issues](https://github.com/peakui-dev/peakui-mcp/issues) ## Links - [npm Package](https://www.npmjs.com/package/@peakui/mcp) - [GitHub Repository](https://github.com/peakui-dev/peakui-mcp) # Introduction > PeakUI is a React component library built on React Aria Components and Tailwind CSS v4, styled with BEM classes and CSS custom properties. **Category**: getting-started **URL**: https://peakui.dev/en/docs/react/getting-started **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/getting-started/index.mdx PeakUI gives you accessible React components whose behavior comes from [React Aria Components](https://react-aria.adobe.com/) and whose styles are plain CSS on top of [Tailwind CSS v4](https://tailwindcss.com/). The library ships 77 components with 543 examples in this documentation, and it is growing. ## Why PeakUI? - **Accessible behavior** – Focus management, keyboard interaction and ARIA wiring come from React Aria Components. The accessibility floor is WCAG 2.2 AA, including `forced-colors` mode. - **Styles you can read** – Every component is a [BEM](https://getbem.com/) block in `@peakui/styles`. There is no runtime styling and nothing hidden in JavaScript. - **Themed with CSS variables** – Colors, radius and typography are custom properties. Change one value and every component follows. - **Compound components** – A component is a root plus named parts, such as `Fieldset.Legend`. You compose the parts; the library does not assemble them for you. - **Typed** – Props, variants and render props are fully typed. - **React 19** – `ref` is an ordinary prop, and every component is a client component. ## Packages | Package | Purpose | | ---------------- | --------------------------------------------------------------------------------------- | | `@peakui/react` | The React components. Everything is exported from the package root. | | `@peakui/styles` | The stylesheet, the theme tokens and the variant functions. It has no React dependency. | ## How a component is built Each component is a thin styled composition over a React Aria primitive: ```tsx import {Button} from "@peakui/react"; ``` - `variant` and `size` pick BEM modifier classes: `.button--secondary`, `.button--md`. - `onPress`, `isDisabled` and `isPending` are React Aria props. - The rendered element carries `data-slot="button"` and state attributes such as `data-hovered` and `data-pressed`, which the CSS styles against. ## What PeakUI does not have A few conventions from other libraries do not exist here, and it helps to know that early: - No provider component. The theme is CSS, so there is nothing to wrap your app in. - No `classNames` prop. Style a part by passing `className` to that part. - No `as` prop. Polymorphism goes through the `render` prop. - No `color` prop on `Button`. The look is chosen with `variant`. - No deep imports. `@peakui/react/button` does not resolve; import from `@peakui/react`. ## Next steps - [Quick Start](https://peakui.dev/docs/react/getting-started/quick-start) – install the packages and render a component. - [Design Principles](https://peakui.dev/docs/react/getting-started/design-principles) – the ten decisions behind the API. - [Theming](https://peakui.dev/docs/react/getting-started/theming) – the tokens and how to change them. - [Styling](https://peakui.dev/docs/react/getting-started/styling) – the ways to restyle a component. - [Composition](https://peakui.dev/docs/react/getting-started/composition) – compound parts, the `render` prop and variant functions. - [All Components](https://peakui.dev/docs/react/components) # All Releases > Every PeakUI release — new features, fixes, and breaking changes. **Category**: releases **URL**: https://peakui.dev/en/docs/react/releases **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/releases/index.mdx PeakUI publishes `@peakui/react` and `@peakui/styles` in lockstep: one release, one version number, notes for both packages. ## Releases - [v0.0.1](https://peakui.dev/docs/react/releases/v0-0-1) — October 2026. Initial public release. The full changelog lives in each package's `CHANGELOG.md` and on the [GitHub Releases page](https://github.com/peakui-dev/peakui/releases). # v0.0.1 > Initial public release of @peakui/react and @peakui/styles. **Category**: releases **URL**: https://peakui.dev/en/docs/react/releases/v0-0-1 **Source**: https://raw.githubusercontent.com/peakui-dev/peakui/refs/heads/main/apps/docs/content/docs/en/react/releases/v0-0-1.mdx **October 2026** First public release. `@peakui/react` and `@peakui/styles` publish in lockstep from the npm organization [`peakui`](https://www.npmjs.com/org/peakui). ## Installing ```bash npm install @peakui/react @peakui/styles ``` ## What shipped - **Components** built on React Aria Components: buttons and toggles, forms and text inputs, pickers (select, combo box, autocomplete, date and range pickers, calendars), colour components, overlays (modal, drawer, popover, tooltip, toast, alert dialog), navigation, feedback (alert, progress, meter, skeleton, spinner), data display and layout. - **`@peakui/styles`** — the design-token layer, base styles, the default theme and the component styles every `@peakui/react` component renders against. - **Docs** — a page for every component at [Components](https://peakui.dev/docs/react/components). ## Full changelog [v0.0.1 on GitHub](https://github.com/peakui-dev/peakui/releases/tag/v0.0.1).