Skip to content

React Aria prompt

Rules that make your coding agent write React Aria Components 1.22 as they work today: onPress and isDisabled, render props, data attributes, collections and validated forms.

What it makes your agent good at

Agents write React Aria like plain React: onClick, disabled, hand-wired ids and data-state selectors, plus APIs 1.22 deprecated. This prompt gives them the current model: React Aria's prop names, parts that wire themselves through context, data attributes for styling, keyed collections, native form validation, and a RouterProvider for links.

  1. Current props, current namesonPress, isDisabled, isSelected and isOpen; CheckboxField, value and onChange instead of the APIs 1.22 deprecated.
  2. Parts that wire themselvesLabel, Input, Text and FieldError inside their field, Popover inside its trigger: no ids or aria wiring by hand.
  3. Styling from render propsdata-pressed, data-selected, data-focus-visible and data-entering as Tailwind variants, composeRenderProps in wrappers.
  4. Collections that stay in syncitems with ids and a render function, textValue, sections, selection sets and dependencies for outside state.
  5. Forms and routingNative validation, validate with a schema, Form validationErrors from the server and RouterProvider for links.
  6. Locale and RTLI18nProvider, @internationalized/date values and logical utilities, so dates, numbers and layout follow the locale.

The React Aria rules

132 lines, current to React Aria Components 1.22, React 19.3 and Tailwind CSS 4.3. Last reviewed October 23, 2026. Plain Markdown, no front matter: each agent's is below.

Download

react-aria.md

# React Aria

You are working in a React 19 project that builds accessible components with React Aria Components (`react-aria-components` 1.x) and TypeScript, styled with Tailwind CSS v4. Write code for the version in `package.json`, not the one in your training data: several APIs you remember are deprecated in the installed version.

## Before you write code

- Read the types for the component you use: `node_modules/react-aria-components/dist/types/src/<Component>.d.ts`. Each render prop documents its data attribute (`@selector [data-pressed]`) and `@deprecated` marks what to avoid.
- Check `components/ui/` (or the project's equivalent) for wrappers and extend them instead of importing primitives into pages.
- Check the global CSS for `@plugin "tailwindcss-react-aria-components"`. If it is there, use its shorthand variants as the existing code does; otherwise use the `data-*` variants below.
- The package imports `client-only`: files that use it are Client Components (`"use client"` at the top in Next.js), and Server Components pass data to them as props.

## Components and props

- Import components from `react-aria-components`. Props use React Aria's names: `onPress`, `isDisabled`, `isSelected`, `isOpen`/`onOpenChange`, `isRequired`, `isInvalid`, `isReadOnly`. `onClick` on Button is only a discouraged alias: use `onPress`, which behaves the same for mouse, touch, keyboard and screen readers.
- Compose parts inside their parent and let context wire them: `Label`, `Input`, `Text slot="description"` and `FieldError` inside `TextField`; a `Button` and a `Popover` inside `Select`, `ComboBox`, `MenuTrigger` or `DialogTrigger`. Do not add `id`, `htmlFor` or `aria-labelledby` by hand.
- Use `isPending` on Button for loading: it keeps focus and announces progress. Buttons are `type="button"` unless you say `type="submit"`.
- In 1.22 these are deprecated: `Checkbox`, `Radio` and `Switch` (use `CheckboxField` with `CheckboxButton`, `RadioField` with `RadioButton`, `SwitchField` with `SwitchButton`); `Section` (use `ListBoxSection`, `MenuSection` and the other named sections); `selectedKey`, `defaultSelectedKey` and `onSelectionChange` on Select and ComboBox (use `value`, `defaultValue` and `onChange`, with `selectionMode="multiple"` for several); `selectedItem` in SelectValue's render props (use `selectedItems`); `validationState` (use `isInvalid`). Keep existing code working, but write new code with the current names.
- Check the exports before building your own: Autocomplete, Tree, Table, GridList, TagGroup, DropZone, Disclosure, Toolbar and the date and color pickers already exist. Toast is still `UNSTABLE_`-prefixed.

## Styling with render props and data attributes

- `className`, `style` and `children` accept a value or a function of render props: `className={({ isSelected }) => …}`, `{({ isOpen }) => …}`.
- Each state is also a data attribute, so Tailwind v4 variants work without functions: `data-hovered:bg-accent data-pressed:scale-[0.98] data-focus-visible:outline-2 data-selected:bg-primary data-disabled:opacity-50 data-invalid:border-destructive`. Others: `data-focused`, `data-open`, `data-expanded`, `data-indeterminate`, `data-placeholder`, `data-empty`, `data-entering`, `data-exiting`, `data-placement`.
- Prefer `data-hovered` and `data-focus-visible` to `hover:` and `focus:`: React Aria ignores emulated hover on touch and shows focus rings for keyboard users only. Style children with `group` and `group-data-selected:`.
- A string `className` replaces the default `react-aria-*` class. In wrappers, keep the caller's function working:

```tsx
import { Button as AriaButton, type ButtonProps, composeRenderProps } from "react-aria-components";
import { cn } from "@/lib/utils";

export function Button({ className, ...props }: ButtonProps) {
  return (
    <AriaButton
      {...props}
      className={composeRenderProps(className, (cls) =>
        cn("inline-flex h-9 items-center gap-2 rounded-md px-4 data-focus-visible:outline-2", cls),
      )}
    />
  );
}
```

- Popovers set `--trigger-width` (use `w-(--trigger-width)` for Select and ComboBox lists) and `--trigger-anchor-point` (use `origin-(--trigger-anchor-point)`). Animate with `data-entering:` and `data-exiting:` transitions or keyframes: React Aria keeps the overlay mounted until the exit animation ends.
- To render a router link or a Motion element, use `render={(props, renderProps) => <motion.button {...props} />}`. Render the same element type and spread `props`: they include the ref.

## Collections

- Collection components (ListBox, Menu, Select, ComboBox, GridList, Table, Tree, TagGroup) take static children or `items` with a render function:

```tsx
<ListBox aria-label="Members" items={members} selectionMode="multiple">
  {(member) => (
    <ListBoxItem id={member.id} textValue={member.name}>
      <img src={member.avatar} alt="" className="size-6 rounded-full" />
      {member.name}
    </ListBoxItem>
  )}
</ListBox>
```

- Every item needs a unique key: an `id` on the item element, or an `id` field on each object. Give items `textValue` when their children are not plain text, for typeahead and announcements.
- Sections are `ListBoxSection` or `MenuSection` with a `Header`; render a section's own items with `<Collection items={section.children}>`.
- Selection is `selectionMode`, `selectedKeys` and `onSelectionChange(keys)`, where `keys` is a `Set` or `"all"`; `disabledKeys` disables items without removing them. Pass `dependencies={[…]}` when a render function reads state from outside `items`.
- `Menu` handles actions with `onAction(key)`; submenus are `SubmenuTrigger` wrapping a `MenuItem` and a `Popover` with a `Menu`. Use `renderEmptyState` for empty lists.
- Use `useListData` for lists the user edits, `useAsyncList` for loading, paging and sorting, and `useFilter({ sensitivity: "base" })` for locale-aware matching.

## Overlays

- Modal: `DialogTrigger` > `Button` + `ModalOverlay` (backdrop, `isDismissable` to close on outside press) > `Modal` > `Dialog`. Give every Dialog a `<Heading slot="title">`, or an `aria-label`. `Dialog` children can be a function receiving `close`.
- Popover: `DialogTrigger` > `Button` + `Popover` (`placement="bottom start"`, `offset`, `OverlayArrow`) > `Dialog`. Menus, selects and combo boxes bring their own Popover child.
- Tooltip: `TooltipTrigger` > a focusable trigger + `Tooltip`. Tooltips show on hover and keyboard focus only; they never replace an accessible name, so icon-only buttons still get `aria-label`.
- Never add `z-index` stacks or portal code: overlays render in a portal and manage focus, scroll lock and Escape themselves.

## Forms

```tsx
<Form validationErrors={serverErrors} onSubmit={onSubmit}>
  <TextField name="email" type="email" isRequired>
    <Label>Email</Label>
    <Input />
    <Text slot="description">We send the receipt here.</Text>
    <FieldError />
  </TextField>
  <Button type="submit">Save</Button>
</Form>
```

- `validationBehavior` defaults to `"native"`: native constraints (`isRequired`, `minLength`, `pattern`, `type`) and `validate` block submission and show errors after a submit attempt. Use `"aria"` (on the field or the Form) for live validation that does not block submit.
- `validate={(value) => …}` returns an error string, an array of them, or `null`. For a schema, run its `safeParse` in `validate` and return the issue messages.
- Server errors go in `<Form validationErrors={{ email: "Taken" }}>`, keyed by field `name`; they clear when the user edits the field.
- With a form library, pass `isInvalid` and render the library's message as `FieldError` children; give each control `name`, `value` and `onChange` from the library.

## Links, locale and direction

- For client-side navigation, wrap the app in `RouterProvider` once, in a Client Component, so every `href` on Link, MenuItem, ListBoxItem, Tab or Row navigates with your router:

```tsx
"use client";
import { useRouter } from "next/navigation";
import { RouterProvider } from "react-aria-components";

declare module "react-aria-components" {
  interface RouterConfig {
    routerOptions: NonNullable<Parameters<ReturnType<typeof useRouter>["push"]>[1]>;
  }
}

export function Providers({ children }: { children: React.ReactNode }) {
  const router = useRouter();
  return <RouterProvider navigate={router.push}>{children}</RouterProvider>;
}
```

- `I18nProvider locale="…"` sets the locale for formatting and keyboard direction; set `lang` and `dir` on `<html>` yourself (`useLocale()` returns `{ locale, direction }`). Use logical utilities (`ms-*`, `pe-*`, `start-*`) so layouts mirror in RTL.
- Dates are `@internationalized/date` values (`parseDate`, `today(getLocalTimeZone())`), never `Date`. Numbers format through `NumberField`'s `formatOptions`, not by hand.

## Hooks

When no component fits, build with hooks from `react-aria` (`useButton`, `usePress`, `useFocusRing`, `useHover`, `mergeProps`) and state from `react-stately` (`useToggleState`, `useOverlayTriggerState`). Merge every hook's props with `mergeProps` onto one element.

## Do not

- Do not use `onClick`, `disabled`, `checked` or `onSelect`-style props from other libraries, or wrap Aria components in `<label>` or `<div role>` markup.
- Do not write new code with `Checkbox`, `Radio`, `Switch`, `Section`, `selectedKey` or `onSelectionChange` on Select and ComboBox.
- Do not mix in Radix `asChild` or Base UI `render={<Element />}`: React Aria's `render` is a function only.
- Do not import from internal `dist` paths, or reach for `forwardRef` in React 19 wrappers.

## Before you finish

- Run the type checker and the linter and fix what they report; heed deprecation warnings.
- Use every component you touched with the keyboard alone (Tab, arrows, Home, End, typeahead, Enter, Space, Escape) and check focus rings appear only for keyboard use.
- Check labels and errors are announced, overlays trap and return focus, and the layout mirrors with `dir="rtl"`.

9,984 characters, 1,295 words. Under Windsurf's 12,000-character limit for a rule, as every prompt here is.

Use it in your agent

The same rules, where your agent reads them. Each file has the front matter its agent needs, set to apply on every request.

Claude Code

A rule it loads every session

  1. Save it as .claude/rules/react-aria.md in your project, front matter included, or run the install command.
  2. Claude Code loads every file in .claude/rules with your CLAUDE.md when a session starts.
  3. Prefer one file? Paste it into CLAUDE.md under its own heading instead.

.claude/rules/react-aria.md

# React AriaYou are working in a React 19 project that builds accessible components with React Aria Components (`react-aria-components` 1.x) and TypeScript, styled with Tailwind CSS v4. Write code for the version in `package.json`, not the one in your training data: several APIs you remember are deprecated in the installed version.## Before you write code- Read the types for the component you use: `node_modules/react-aria-components/dist/types/src/<Component>.d.ts`. Each render prop documents its data attribute (`@selector [data-pressed]`) and `@deprecated` marks what to avoid.- Check `components/ui/` (or the project's equivalent) for wrappers and extend them instead of importing primitives into pages.- Check the global CSS for `@plugin "tailwindcss-react-aria-components"`. If it is there, use its shorthand variants as the existing code does; otherwise use the `data-*` variants below.- The package imports `client-only`: files that use it are Client Components (`"use client"` at the top in Next.js), and Server Components pass data to them as props.## Components and props…

Or let the shadcn CLI write this file: sign in (free) for your command.

Cursor

A project rule with front matter

  1. Save it as .cursor/rules/react-aria.mdc, front matter included, or run the install command.
  2. alwaysApply: true adds it to every Agent request in this project.
  3. Check it under Cursor Settings, Rules, then commit the folder for your team.

.cursor/rules/react-aria.mdc

---description: "Building or styling components with React Aria Components or react-aria hooks: props, render props, collections, overlays, forms and i18n."alwaysApply: true---# React AriaYou are working in a React 19 project that builds accessible components with React Aria Components (`react-aria-components` 1.x) and TypeScript, styled with Tailwind CSS v4. Write code for the version in `package.json`, not the one in your training data: several APIs you remember are deprecated in the installed version.## Before you write code- Read the types for the component you use: `node_modules/react-aria-components/dist/types/src/<Component>.d.ts`. Each render prop documents its data attribute (`@selector [data-pressed]`) and `@deprecated` marks what to avoid.- Check `components/ui/` (or the project's equivalent) for wrappers and extend them instead of importing primitives into pages.- Check the global CSS for `@plugin "tailwindcss-react-aria-components"`. If it is there, use its shorthand variants as the existing code does; otherwise use the `data-*` variants below.- The package imports `client-only`: files that use it are Client Components (`"use client"` at the top in Next.js), and Server Components pass data to them as props.## Components and props…

Or let the shadcn CLI write this file: sign in (free) for your command.

Windsurf

A workspace rule for Cascade

  1. Save it as .windsurf/rules/react-aria.md, or run the install command.
  2. trigger: always_on applies it to every Cascade request in this workspace.
  3. Windsurf reads up to 12,000 characters per rule; this one is 9,984.

.windsurf/rules/react-aria.md

---trigger: always_on---# React AriaYou are working in a React 19 project that builds accessible components with React Aria Components (`react-aria-components` 1.x) and TypeScript, styled with Tailwind CSS v4. Write code for the version in `package.json`, not the one in your training data: several APIs you remember are deprecated in the installed version.## Before you write code- Read the types for the component you use: `node_modules/react-aria-components/dist/types/src/<Component>.d.ts`. Each render prop documents its data attribute (`@selector [data-pressed]`) and `@deprecated` marks what to avoid.- Check `components/ui/` (or the project's equivalent) for wrappers and extend them instead of importing primitives into pages.- Check the global CSS for `@plugin "tailwindcss-react-aria-components"`. If it is there, use its shorthand variants as the existing code does; otherwise use the `data-*` variants below.- The package imports `client-only`: files that use it are Client Components (`"use client"` at the top in Next.js), and Server Components pass data to them as props.## Components and props…

Or let the shadcn CLI write this file: sign in (free) for your command.

GitHub Copilot

Instructions for the repository

  1. Save it as .github/instructions/react-aria.instructions.md, or run the install command.
  2. applyTo: "**" applies it to every request in this repository.
  3. Or paste it into .github/copilot-instructions.md, which Copilot reads for every request.

.github/instructions/react-aria.instructions.md

---description: "Building or styling components with React Aria Components or react-aria hooks: props, render props, collections, overlays, forms and i18n."applyTo: "**"---# React AriaYou are working in a React 19 project that builds accessible components with React Aria Components (`react-aria-components` 1.x) and TypeScript, styled with Tailwind CSS v4. Write code for the version in `package.json`, not the one in your training data: several APIs you remember are deprecated in the installed version.## Before you write code- Read the types for the component you use: `node_modules/react-aria-components/dist/types/src/<Component>.d.ts`. Each render prop documents its data attribute (`@selector [data-pressed]`) and `@deprecated` marks what to avoid.- Check `components/ui/` (or the project's equivalent) for wrappers and extend them instead of importing primitives into pages.- Check the global CSS for `@plugin "tailwindcss-react-aria-components"`. If it is there, use its shorthand variants as the existing code does; otherwise use the `data-*` variants below.- The package imports `client-only`: files that use it are Client Components (`"use client"` at the top in Next.js), and Server Components pass data to them as props.## Components and props…

Or let the shadcn CLI write this file: sign in (free) for your command.

Codex & AGENTS.md

The file most agents read

  1. Paste it into AGENTS.md at your project's root, under its own heading.
  2. Codex reads AGENTS.md before it starts work, and so do Cursor, Zed, Jules, Amp and Copilot's coding agent.
  3. A folder can have its own AGENTS.md: the one closest to the file being edited wins.

AGENTS.md

## React AriaYou are working in a React 19 project that builds accessible components with React Aria Components (`react-aria-components` 1.x) and TypeScript, styled with Tailwind CSS v4. Write code for the version in `package.json`, not the one in your training data: several APIs you remember are deprecated in the installed version.### Before you write code- Read the types for the component you use: `node_modules/react-aria-components/dist/types/src/<Component>.d.ts`. Each render prop documents its data attribute (`@selector [data-pressed]`) and `@deprecated` marks what to avoid.- Check `components/ui/` (or the project's equivalent) for wrappers and extend them instead of importing primitives into pages.- Check the global CSS for `@plugin "tailwindcss-react-aria-components"`. If it is there, use its shorthand variants as the existing code does; otherwise use the `data-*` variants below.- The package imports `client-only`: files that use it are Client Components (`"use client"` at the top in Next.js), and Server Components pass data to them as props.### Components and props…

AGENTS.md is shared with your own instructions, so paste the rules in: the copy sets their headings a level down.

Rules teach it. The MCP equips it. With Pro, your agent installs every component, block and icon it needs, from a prompt.

Get Pro

Pricing

Give your agent the parts, with Pro

The prompts are free. Every Pro plan adds the MCP server, so your agent installs the components, blocks and icons it writes code around.

4.9/5 out of 5 · 150+ reviewsfrom 150+ founders and developers.

Billed once a year in USD. Cancel anytime.

Individual

For personal projects & open source

$32instead of $49/mo

$389 billed yearly

  • How many people can use the license.Seats: 1 seat
  • Client work, SaaS products and anything you charge for.Commercial use: Personal & open source only
  • Page sections in 56 categories, from heroes and pricing tables to dashboards and settings, on every framework and UI library, in your theme.Blocks: All 6,181 blocks
  • Complete Next.js sites for startups, SaaS, agencies and portfolios, every page designed, ready to ship.Templates: All 14 templates
  • Your AI agent searches, previews and installs any component, block, icon or DESIGN.md from a prompt: 22 tools in Claude Code, Cursor, VS Code and 35 more clients.MCP server: 38 AI clients
  • Buttons with motion and states of their own, from an arrow that slides in to a burst of confetti.Animated buttons: All 35 buttons
  • Typewriters, scrambles, counters and more, for headlines, labels and numbers.Text effects: All 97 effects
  • Animated backgrounds for heroes, sections and cards, from a soft aurora to a flock that flees the cursor. Most are pure CSS.Backgrounds: All 100 backgrounds
  • WebGPU shaders, from a slow aurora to a black hole, each drawing only while it's on screen.Shaders: All 100 shaders
  • One design and one theme on all four: the components, blocks and effects are built for each framework.Frameworks: React, Vue, Svelte, Solid
  • React on Base UI, Radix UI, React Aria or Ark UI: install the version for the library your project already uses. Vue, Svelte and Solid run on Ark UI.UI libraries: Base UI, Radix, Aria, Ark
  • From a button to a date picker, a color picker or a guided tour: accessible, typed in TypeScript, each with live demos.Components: All 174 components
  • Real-world patterns built from the components, in 53 galleries: forms, tables, menus, dialogs and more.Examples: All 1,103 examples
  • Area, bar, line, pie, radar and radial charts on TanStack Charts, on every framework. React also gets the Recharts originals.Charts: All 70 charts
  • Debounce, local storage, media queries and more: each hook is one typed file you own.React hooks: All 35 hooks
  • From 222 libraries, Lucide, Heroicons, Tabler and Material Symbols among them, as SVG or a React component in one command.Icons: 294k+ icons
  • Stripe, Linear, Apple and 497 more: a brand's colors, typography and components in one file your AI agent builds from.DESIGN.md files: All 500 brands
  • Restyle every component and block at once: 8 styles, 7 grays, 18 colors and 5 radii, shared as a shadcn preset code.Theme builder: 8 styles × 18 colors
  • Priority requests are answered first.Support: Standard

Team

Most popular

For freelancers, agencies & startups

$66instead of $99/mo

$789 billed yearly · ≈ $13/dev/mo

Everything in Individual, plus

  • How many people can use the license.Seats: Up to 5 seats
  • Client work, SaaS products and anything you charge for.Commercial use: Included
  • Priority requests are answered first.Support: Priority

Organization

For companies with larger teams

$132instead of $199/mo

$1,589 billed yearly

Everything in Team, plus

  • How many people can use the license.Seats: Unlimited seats
  • Secure checkout via Stripe
  • Code lives in your repo
  • Keep what you've shipped if you cancel
  • License terms

React Aria prompt FAQ

What the React Aria prompt covers and how to use it in your agent.

What does the React Aria prompt say is deprecated in 1.22?

Checkbox, Radio and Switch are deprecated in favor of CheckboxField with CheckboxButton, RadioField with RadioButton and SwitchField with SwitchButton. Section gives way to ListBoxSection and MenuSection, and Select and ComboBox take value, defaultValue and onChange instead of selectedKey and onSelectionChange.

Why does the React Aria prompt insist on onPress over onClick?

onPress fires the same way for mouse, touch, keyboard and screen readers, and it ignores the browser quirks onClick has on touch screens. The prompt makes the agent use onPress, isDisabled, isSelected and isOpen, the names React Aria components expect, instead of the DOM props it reaches for by habit.

How does the render prop work in React Aria Components?

It is a function, not an element: render={(props, renderProps) => <motion.button {...props} />}. The prompt has the agent render the same element type and spread the props, which include the ref, so a router link or a Motion component keeps React Aria's behavior.

4.9 out of 5 from 150+ developers

Rules teach it. The MCP equips it.

Every component, block and icon, installed by your AI agent on your stack. The prompts stay free.

Get Pro
  • Cancel anytime
  • Keep what you've shipped