--- name: radix-ui description: Expert guidance for building React UIs with Radix Themes and Radix Primitives. Use when creating accessible, customisable UI components, setting up theming systems, working with pre-styled Radix Themes components, or building custom components on top of unstyled Radix Primitives. Trigger keywords include "radix", "radix ui", "radix themes", "radix primitives", "accessible components", "Dialog", "Dropdown", "Select", "Accordion", "Tabs", "Tooltip". --- # Radix UI Radix provides two complementary libraries for React: - **Radix Themes**: Pre-styled, ready-to-use component library with built-in theming - **Radix Primitives**: Unstyled, accessible component primitives for custom design systems ## Choosing Between Themes and Primitives **Use Radix Themes when:** - Building applications quickly with minimal styling effort - Wanting a consistent, polished design out of the box - Theming via configuration props is sufficient **Use Radix Primitives when:** - Building a custom design system with complete styling control - Integrating with existing styling solutions (Tailwind, styled-components, CSS modules) - Needing only specific components without a full theme system ## Quick Start ### Radix Themes Setup ```bash npm install @radix-ui/themes ``` ```tsx import "@radix-ui/themes/styles.css"; import { Theme } from "@radix-ui/themes"; export default function App() { return ( ); } ``` ### Radix Primitives Setup Install individual components: ```bash npm install @radix-ui/react-dialog @radix-ui/react-dropdown-menu ``` Or install the full package: ```bash npm install radix-ui ``` ## Radix Themes ### Theme Configuration The `Theme` component accepts these props: | Prop | Values | Default | | ----------------- | ------------------------------------- | ----------- | | `accentColor` | indigo, cyan, crimson, orange, etc. | indigo | | `grayColor` | gray, mauve, slate, sage, olive, sand | gray | | `radius` | none, small, medium, large, full | medium | | `scaling` | 90%, 95%, 100%, 105%, 110% | 100% | | `panelBackground` | solid, translucent | translucent | ### Component Variants Most Themes components support these variant props: ```tsx ), ); ``` ### Styling Primitives **With CSS classes:** ```tsx ``` **With data attributes for state:** ```css .accordion-item[data-state="open"] { background: var(--accent-3); } .accordion-item[data-state="closed"] { background: transparent; } ``` **With Tailwind CSS:** ```tsx ``` For complete Primitives patterns, see [references/primitives-patterns.md](references/primitives-patterns.md). ## Accessibility Radix Primitives implement WAI-ARIA patterns automatically: - Focus management and trapping (modals) - Keyboard navigation (arrow keys, Tab, Escape) - Screen reader announcements - Proper ARIA attributes Ensure custom implementations maintain accessibility: ```tsx // Dialog requires Title for screen readers Required for a11y {/* If no description, set aria-describedby={undefined} on Content */} ```