### Run Development Server with npm
Source: https://github.com/radix-ui/themes/blob/main/apps/playground/README.md
Use this command to start the Next.js development server using npm. Open http://localhost:3000 in your browser to view the application.
```bash
npm run dev
```
--------------------------------
### Run Development Server with bun
Source: https://github.com/radix-ui/themes/blob/main/apps/playground/README.md
Use this command to start the Next.js development server using bun. Open http://localhost:3000 in your browser to view the application.
```bash
bun dev
```
--------------------------------
### Install Dependencies with pnpm
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Use this command to install all project dependencies in the monorepo.
```bash
pnpm install
```
--------------------------------
### Run Development Server with yarn
Source: https://github.com/radix-ui/themes/blob/main/apps/playground/README.md
Use this command to start the Next.js development server using yarn. Open http://localhost:3000 in your browser to view the application.
```bash
yarn dev
```
--------------------------------
### Run Development Server with pnpm
Source: https://github.com/radix-ui/themes/blob/main/apps/playground/README.md
Use this command to start the Next.js development server using pnpm. Open http://localhost:3000 in your browser to view the application.
```bash
pnpm dev
```
--------------------------------
### Install Radix Themes
Source: https://context7.com/radix-ui/themes/llms.txt
Install the Radix Themes package using npm. This command adds the library to your project dependencies.
```bash
npm install @radix-ui/themes
```
--------------------------------
### TextField with Icons and Clear Button
Source: https://context7.com/radix-ui/themes/llms.txt
Use TextField.Root with TextField.Slot for leading/trailing icons or buttons. The example shows a search input with a magnifying glass icon and a clear button, and a password field with a reveal toggle.
```tsx
import * as TextField from '@radix-ui/themes/components/text-field';
// or namespace: import { TextField } from '@radix-ui/themes';
import { IconButton, Flex, Text } from '@radix-ui/themes';
import { MagnifyingGlassIcon, Cross2Icon, EyeOpenIcon } from '@radix-ui/react-icons';
import * as React from 'react';
export default function Example() {
const [query, setQuery] = React.useState('');
const [showPwd, setShowPwd] = React.useState(false);
return (
{/* Search with left icon and clear button */}
setQuery(e.target.value)}
>
{query && (
setQuery('')}>
)}
{/* Password field with reveal toggle */}
setShowPwd(!showPwd)}>
);
}
```
--------------------------------
### Avatar Component Examples
Source: https://context7.com/radix-ui/themes/llms.txt
Avatar displays user images with fallback text or icons. It handles loading states and supports different sizes, variants, and colors. Ensure fallback is provided.
```tsx
import { Flex, Avatar, Text } from '@radix-ui/themes';
const users = [
{ name: 'Alice Johnson', src: 'https://i.pravatar.cc/150?img=1', id: 1 },
{ name: 'Bob Smith', src: '/broken-image.png', id: 2 }, // will show fallback
{ name: 'Charlie Brown', src: undefined, id: 3 },
];
export default function Example() {
return (
{users.map((user) => (
{user.name}
))}
{/* Variant "solid" for high-contrast fallbacks */}
);
}
```
--------------------------------
### Switch with Size Variants and Color Options
Source: https://context7.com/radix-ui/themes/llms.txt
The Switch component functions as a binary on/off toggle. It supports controlled and uncontrolled states similar to Checkbox. This example demonstrates different sizes, colors, and variants.
```tsx
import { Switch, Flex, Text } from '@radix-ui/themes';
import * as React from 'react';
export default function Example() {
const [enabled, setEnabled] = React.useState(false);
return (
{enabled ? 'Notifications on' : 'Notifications off'}
{/* Size variants */}
);
}
```
--------------------------------
### Access Theme Context with useThemeContext
Source: https://context7.com/radix-ui/themes/llms.txt
Use the `useThemeContext` hook inside a `` tree to access current theme values and change handlers. This example demonstrates toggling the appearance.
```tsx
import { Theme, useThemeContext, Button, Flex, Text } from '@radix-ui/themes';
function ThemeInfo() {
const {
appearance,
accentColor,
radius,
scaling,
onAppearanceChange,
} = useThemeContext();
return (
Appearance: {appearance}Accent: {accentColor}Radius: {radius}Scaling: {scaling}
);
}
export default function App() {
return (
);
}
```
--------------------------------
### Badge Component Examples
Source: https://context7.com/radix-ui/themes/llms.txt
Use Badge for status labels, counts, and categories. Supports various colors, variants, sizes, and can be rendered as a link using asChild.
```tsx
import { Flex, Badge, Text } from '@radix-ui/themes';
export default function Example() {
return (
ActiveErrorWarningv3.3.0Draft
{/* asChild: renders badge as a link */}
View statusNotifications12
);
}
```
--------------------------------
### Card Component Examples
Source: https://context7.com/radix-ui/themes/llms.txt
Card provides a bordered, rounded container for grouping content. Use it for distinct sections, with variants for different visual elevations. Supports edge-to-edge content via Inset and can be interactive with asChild.
```tsx
import { Card, Flex, Avatar, Text, Badge, Button, Box, Inset } from '@radix-ui/themes';
export default function Example() {
return (
{/* Basic card */}
Jane DoeSoftware Engineer
{/* Card with Inset for edge-to-edge image */}
Card with edge-to-edge image header.
{/* Interactive card via asChild */}
View profile →
);
}
```
--------------------------------
### Build the Library
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Builds all packages within the monorepo.
```bash
pnpm build
```
--------------------------------
### Build Only the Themes Package
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Builds only the `@radix-ui/themes` package.
```bash
pnpm build:pkg
```
--------------------------------
### Flex and Grid Layouts with Responsiveness
Source: https://context7.com/radix-ui/themes/llms.txt
Illustrates the use of Flex and Grid layout primitives for structuring content, demonstrating responsive properties for direction, alignment, and column counts. Requires Box, Text, and Button imports.
```tsx
import { Flex, Grid, Box, Text, Button } from '@radix-ui/themes';
export default function Example() {
return (
// Flex: direction, align, justify, gap, wrap are responsive
Sidebar
{/* Grid: 1 column on mobile, 3 on sm+ */}
{['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta'].map((name) => (
{name}
))}
);
}
```
--------------------------------
### Lint All Code
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Runs ESLint and Stylelint across the entire monorepo to check for code quality issues.
```bash
pnpm lint
```
--------------------------------
### Typography with Text and Heading
Source: https://context7.com/radix-ui/themes/llms.txt
Demonstrates the Text and Heading components for rendering typography, showcasing different sizes, weights, colors, alignment, and truncation. Requires Flex import.
```tsx
import { Flex, Heading, Text } from '@radix-ui/themes';
export default function Example() {
return (
Page Title
Subtitle
Body text with bold and{' '}
colored inline spans.
This very long line of text will be truncated with an ellipsis if it overflows its container.
);
}
```
--------------------------------
### Button Variants, Sizes, and States
Source: https://context7.com/radix-ui/themes/llms.txt
Demonstrates different visual styles, sizes, color overrides, loading states, high contrast, and the `asChild` pattern for the Button component. Ensure necessary imports are included.
```tsx
import { Button, Flex, Spinner } from '@radix-ui/themes';
export default function Example() {
return (
{/* Variants */}
{/* Sizes: 1–4 */}
{/* Color override */}
{/* Loading state — spinner replaces content, button stays same size */}
{/* High contrast */}
{/* asChild: renders as while keeping Button styles */}
);
}
```
--------------------------------
### IconButton Usage with Tooltips
Source: https://context7.com/radix-ui/themes/llms.txt
Shows how to use the IconButton component for icon-only actions, including applying variants, colors, sizes, and integrating with Tooltips for accessibility. Requires importing icons and Tooltip.
```tsx
import { IconButton, Flex, Tooltip } from '@radix-ui/themes';
import { MagnifyingGlassIcon, GearIcon, PlusIcon } from '@radix-ui/react-icons';
export default function Example() {
return (
);
}
```
--------------------------------
### Import Radix Themes Stylesheet
Source: https://context7.com/radix-ui/themes/llms.txt
Import the main stylesheet for Radix Themes at your application's entry point. This ensures all theme styles are applied globally.
```tsx
import '@radix-ui/themes/styles.css';
```
--------------------------------
### Root Theme Provider with Nested Overrides
Source: https://context7.com/radix-ui/themes/llms.txt
Use the `Theme` component to wrap your application and provide design tokens. Nested `Theme` components can override specific tokens for isolated sections.
```tsx
import { Theme, Button, Flex, Text } from '@radix-ui/themes';
import '@radix-ui/themes/styles.css';
export default function App() {
return (
// Root theme: dark, indigo accent, medium radius, 100% scale
Hello, Radix Themes
{/* Nested theme overrides only accentColor */}
);
}
```
--------------------------------
### Format Code
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Applies code formatting rules (Prettier) to all files in the repository.
```bash
pnpm format
```
--------------------------------
### Check Code Formatting
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Checks if all files adhere to the configured code formatting rules without modifying them.
```bash
pnpm format:check
```
--------------------------------
### Update Visual Regression Snapshots
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Updates the baseline snapshots for visual regression tests. Use this after making intentional UI changes.
```bash
pnpm test:vr:update
```
--------------------------------
### Creating Accessible Modal Dialogs with Dialog
Source: https://context7.com/radix-ui/themes/llms.txt
Implement modal overlays using the Dialog component, which includes trigger, content, title, description, and close buttons. Ensure proper import of Dialog and other necessary UI elements.
```tsx
import * as Dialog from '@radix-ui/themes/components/dialog';
// or namespace: import { Dialog } from '@radix-ui/themes';
import { Button, Flex, TextField, Text } from '@radix-ui/themes';
export default function Example() {
return (
Edit profile
Make changes to your profile information.
);
}
```
--------------------------------
### Interactive Theme Customizer with ThemePanel
Source: https://context7.com/radix-ui/themes/llms.txt
Integrate `ThemePanel` to provide a floating UI panel for users to customize theme settings at runtime. The panel can be toggled with the 'T' key.
```tsx
import { Theme, ThemePanel, Button, Flex } from '@radix-ui/themes';
export default function App() {
return (
{/* defaultOpen=false hides the panel initially; press T to open */}
);
}
```
--------------------------------
### Skeleton Component Usage
Source: https://context7.com/radix-ui/themes/llms.txt
Use the Skeleton component to wrap any other component. It will display an animated loading placeholder when the `loading` prop is true. Ensure necessary components like Avatar, Text, Flex, and Card are imported from '@radix-ui/themes'.
```tsx
import { Skeleton, Avatar, Text, Flex, Card } from '@radix-ui/themes';
import * as React from 'react';
export default function Example() {
const [loading, setLoading] = React.useState(true);
// Simulate data fetch
React.useEffect(() => {
const t = setTimeout(() => setLoading(false), 2000);
return () => clearTimeout(t);
}, []);
return (
Jane Doejane@example.com
);
}
```
--------------------------------
### Theme Component
Source: https://context7.com/radix-ui/themes/llms.txt
The Theme component wraps your application to provide design tokens. It accepts props to control appearance, accent color, gray color, panel background, radius, and scaling. Nested Theme components can override parent settings.
```APIDOC
## Theme Component
### Description
The `Theme` component must wrap your application (or any subtree) to provide design tokens. It sets `appearance` (light/dark), `accentColor`, `grayColor`, `panelBackground`, `radius`, and `scaling`. Nested `Theme` components inherit parent settings and can override individual tokens for isolated sections.
### Props
- **appearance** (`"light" | "dark" | "inherit"`): Controls the light or dark mode of the theme.
- **accentColor** (29 colors, default `"indigo"`): Sets the primary accent color for UI elements.
- **grayColor** (`"auto" | "gray" | "mauve" | "slate" | ...`): Sets the gray color scale for neutral elements.
- **panelBackground** (`"solid" | "translucent"`): Determines the background style of panels.
- **radius** (`"none" | "small" | "medium" | "large" | "full"`): Sets the border radius for components.
- **scaling** (`"90%" | "95%" | "100%" | "105%" | "110%"`): Controls the UI scaling factor.
- **hasBackground** (boolean): Indicates if the theme has a background.
### Example
```tsx
import { Theme, Button, Flex, Text } from '@radix-ui/themes';
import '@radix-ui/themes/styles.css';
export default function App() {
return (
Hello, Radix Themes
);
}
```
```
--------------------------------
### Progress Bar with Determinate and Indeterminate States
Source: https://context7.com/radix-ui/themes/llms.txt
Shows how to use the Radix UI Progress component for both determinate (with a value) and indeterminate (loading) states. Useful for indicating task progress.
```tsx
import { Progress, Flex, Text } from '@radix-ui/themes';
export default function Example() {
return (
{/* Determinate */}
Upload: 75%
{/* Indeterminate (no value prop) — animates indefinitely */}
Processing…
{/* Size and variant */}
);
}
```
--------------------------------
### Create a Tooltip with custom content and behavior
Source: https://context7.com/radix-ui/themes/llms.txt
Use the Tooltip component to wrap any trigger element and display a contextual hover label. Customize content, side, offset, and delay duration.
```tsx
import { Tooltip, IconButton, Flex, Button } from '@radix-ui/themes';
import { InfoCircledIcon, QuestionMarkCircledIcon } from '@radix-ui/react-icons';
export default function Example() {
return (
Learn more at docs}>
);
}
```
--------------------------------
### Render structured data in a Table
Source: https://context7.com/radix-ui/themes/llms.txt
Use the Table component for displaying data in a grid format. Configure table variant, size, and layout. Rows can contain headers and cells, with cells supporting components like Badges.
```tsx
import * as Table from '@radix-ui/themes/components/table';
// or namespace: import { Table } from '@radix-ui/themes';
import { Badge } from '@radix-ui/themes';
const users = [
{ id: 1, name: 'Alice Johnson', email: 'alice@example.com', role: 'Admin', status: 'active' },
{ id: 2, name: 'Bob Smith', email: 'bob@example.com', role: 'Editor', status: 'inactive' },
{ id: 3, name: 'Carol White', email: 'carol@example.com', role: 'Viewer', status: 'active' },
];
export default function Example() {
return (
NameEmailRoleStatus
{users.map((user) => (
{user.name}{user.email}{user.role}
{user.status}
))}
);
}
```
--------------------------------
### Clean Build Artifacts
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Removes all generated build artifacts and temporary files from the repository.
```bash
pnpm clean
```
--------------------------------
### Displaying Inline Alert Messages with Callout
Source: https://context7.com/radix-ui/themes/llms.txt
Use Callout components for prominent informational messages. They require importing the Callout component and relevant icons. Supports different colors, variants, and sizes.
```tsx
import * as Callout from '@radix-ui/themes/components/callout';
// or:
import { Callout } from '@radix-ui/themes'; // namespace import
import { InfoCircledIcon, ExclamationTriangleIcon, CheckCircledIcon } from '@radix-ui/react-icons';
export default function Example() {
return (
Your session will expire in 10 minutes.Error: Could not connect to the database. Please try again.
Deployment successful. Changes are now live.
);
}
```
--------------------------------
### Run Visual Regression Tests
Source: https://github.com/radix-ui/themes/blob/main/AGENTS.md
Executes Playwright visual regression tests to detect unintended UI changes.
```bash
pnpm test:vr
```
--------------------------------
### Tabs Component for Tabbed Content
Source: https://context7.com/radix-ui/themes/llms.txt
Illustrates the structure of the Radix UI Tabs component, including Tabs.Root, Tabs.List, Tabs.Trigger, and Tabs.Content. Use for organizing content into navigable sections.
```tsx
import * as Tabs from '@radix-ui/themes/components/tabs';
// or namespace: import { Tabs } from '@radix-ui/themes';
import { Box, Text, Flex } from '@radix-ui/themes';
export default function Example() {
return (
OverviewSettingsBillingProject statistics and recent activity.Project namemy-awesome-projectManage your subscription and invoices.
);
}
```
--------------------------------
### useThemeContext Hook
Source: https://context7.com/radix-ui/themes/llms.txt
A React hook that returns the current theme context values and change handlers. It must be used inside a `` tree.
```APIDOC
## useThemeContext Hook
### Description
A React hook that returns the current theme context values and change handlers. Must be used inside a `` tree.
### Usage
```tsx
import { Theme, useThemeContext, Button, Flex, Text } from '@radix-ui/themes';
function ThemeInfo() {
const {
appearance,
accentColor,
radius,
scaling,
onAppearanceChange,
} = useThemeContext();
return (
Appearance: {appearance}Accent: {accentColor}Radius: {radius}Scaling: {scaling}
);
}
export default function App() {
return (
);
}
```
### Returns
An object containing the current theme values: `appearance`, `accentColor`, `radius`, `scaling`, and a function `onAppearanceChange` to toggle the appearance.
```
--------------------------------
### Implementing Dropdown Selectors with Select
Source: https://context7.com/radix-ui/themes/llms.txt
Build composable dropdown selectors using the Select component, including root, trigger, content, items, groups, labels, and separators. Manage the selected value using React state.
```tsx
import * as Select from '@radix-ui/themes/components/select';
// or namespace: import { Select } from '@radix-ui/themes';
import { Flex, Text } from '@radix-ui/themes';
import * as React from 'react';
export default function Example() {
const [framework, setFramework] = React.useState('nextjs');
return (
ReactNext.jsRemixViteVueNuxtQuasarSelected: {framework}
);
}
```
--------------------------------
### ThemePanel Component
Source: https://context7.com/radix-ui/themes/llms.txt
A floating UI panel that allows users to customize theme settings at runtime. It can be toggled with the 'T' key or programmatically and includes a 'Copy Theme' button.
```APIDOC
## ThemePanel Component
### Description
A floating UI panel (toggled with the `T` key or programmatically) that lets users pick accent color, gray color, appearance, radius, scaling, and panel background at runtime, with a "Copy Theme" button that writes the resulting `` JSX to the clipboard.
### Props
- **defaultOpen** (boolean, default `false`): Controls whether the panel is open by default.
### Example
```tsx
import { Theme, ThemePanel, Button, Flex } from '@radix-ui/themes';
export default function App() {
return (
);
}
```
```
--------------------------------
### Tabs
Source: https://context7.com/radix-ui/themes/llms.txt
Accessible tabbed navigation composed of `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, and `Tabs.Content`. Allows for structured content display with customizable list and trigger props.
```APIDOC
## Tabs — Tabbed content panels
Accessible tabbed navigation using `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, and `Tabs.Content`.
### Props:
**`Tabs.Root` props:** `defaultValue`, `value`, `onValueChange`, `orientation`. **`Tabs.List` props:** `size` (`"1"–"2"`), `color`, `highContrast`. **`Tabs.Content` props:** `value` (required).
```
--------------------------------
### Display labeled data with DataList
Source: https://context7.com/radix-ui/themes/llms.txt
Utilize the DataList component for semantic key-value pairs. Configure orientation, size, and trim behavior. Labels and values can include other components like Links and Badges.
```tsx
import * as DataList from '@radix-ui/themes/components/data-list';
// or namespace: import { DataList } from '@radix-ui/themes';
import { Badge, Link, Code } from '@radix-ui/themes';
const user = {
name: 'Jane Doe',
email: 'jane@example.com',
role: 'Admin',
status: 'active',
joined: '2022-03-15',
userId: 'usr_8f2a9c1d',
};
export default function Example() {
return (
Name{user.name}Email
{user.email}
Status{user.status}User ID{user.userId}
);
}
```
--------------------------------
### Progress
Source: https://context7.com/radix-ui/themes/llms.txt
A visual indicator for task completion, which can be determinate or indeterminate. It offers customization for value, max, duration, size, variant, and color.
```APIDOC
## Progress — Progress bar
A visual indicator for task completion with optional indeterminate animation.
### Props:
`value` (omit for indeterminate), `max` (default 100), `duration` (CSS time string for indeterminate animation), `size` (`"1"–"3"`), `variant` (`"classic" | "surface" | "soft"`), `color`, `radius`, `highContrast`.
```
--------------------------------
### Slider with Single and Multi-Thumb Modes
Source: https://context7.com/radix-ui/themes/llms.txt
Demonstrates the Radix UI Slider component in both single-thumb and range (two-thumb) configurations. Use to control numerical values within a defined range.
```tsx
import { Slider, Flex, Text } from '@radix-ui/themes';
import * as React from 'react';
export default function Example() {
const [volume, setVolume] = React.useState([60]);
const [range, setRange] = React.useState([20, 80]);
return (
{/* Single-thumb */}
Volume: {volume[0]}%
{/* Range (two thumbs) */}
Price: ${range[0]} – ${range[1]}
);
}
```
--------------------------------
### Slider
Source: https://context7.com/radix-ui/themes/llms.txt
A draggable range slider that supports single and multi-thumb modes. It can be customized with various props for min, max, step, size, color, and more.
```APIDOC
## Slider — Range input
A draggable range slider supporting single and multi-thumb modes.
### Props:
`value`, `defaultValue`, `onValueChange`, `min`, `max`, `step`, `size` (`"1"–"3"`), `variant` (`"classic" | "surface" | "soft"`), `color`, `radius`, `highContrast`, `inverted`, `orientation`.
```
--------------------------------
### SegmentedControl for Mutually Exclusive Options
Source: https://context7.com/radix-ui/themes/llms.txt
Demonstrates the Radix UI SegmentedControl component for selecting one option from a group. It functions similarly to radio buttons but is presented as a segmented button group.
```tsx
import * as SegmentedControl from '@radix-ui/themes/components/segmented-control';
// or namespace: import { SegmentedControl } from '@radix-ui/themes';
import { Flex } from '@radix-ui/themes';
import * as React from 'react';
export default function Example() {
const [view, setView] = React.useState('grid');
return (
ListGridKanban
);
}
```
--------------------------------
### Checkbox with Controlled, Indeterminate, and Uncontrolled States
Source: https://context7.com/radix-ui/themes/llms.txt
The Checkbox component supports controlled and uncontrolled states, as well as an indeterminate checked value. Use onCheckedChange for controlled states and defaultChecked for uncontrolled ones.
```tsx
import { Checkbox, Flex, Text } from '@radix-ui/themes';
import * as React from 'react';
export default function Example() {
const [checked, setChecked] = React.useState(false);
return (
{/* Controlled */}
setChecked(val)}
size="2"
color="indigo"
/>
Accept terms and conditions
{/* Indeterminate state */}
Select all (partial)
{/* Uncontrolled with default */}
Receive newsletter
);
}
```
--------------------------------
### SegmentedControl
Source: https://context7.com/radix-ui/themes/llms.txt
A mutually exclusive option selector presented as a segmented button group, similar to radio buttons. Supports value, defaultValue, onValueChange, size, radius, and disabled states.
```APIDOC
## SegmentedControl — Button group selector
A mutually exclusive option selector, similar to radio buttons but displayed as a segmented button group.
### Props:
**`SegmentedControl.Root` props:** `size` (`"1"–"3"`), `value`, `defaultValue`, `onValueChange`, `radius`, `disabled`. **`SegmentedControl.Item` props:** `value` (required).
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.