# Radix Themes Native Documentation
> A React Native port of Radix Themes - An open-source component library optimized for fast development, easy maintenance, and accessibility.
## Installation
```bash
npm install radix-native-ui
```
## Peer Dependencies
- `react` >= 18
- `react-native` >= 0.70
- `expo` >= 48
## Quick Start
```tsx
import { ThemeProvider, Button, Text, Flex, Card, Heading } from 'radix-native-ui';
export default function App() {
return (
Welcome
Build beautiful mobile apps with Radix Themes Native.
);
}
```
---
## ThemeProvider
Wrap your app with ThemeProvider to enable theming.
### Props
#### Theme Configuration
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `accentColor` | `Color` | `'indigo'` | Primary accent color for the theme |
| `grayColor` | `'mauve' \| 'olive' \| 'sage' \| 'sand' \| 'slate' \| 'gray'` | `'mauve'` | Gray scale color |
| `radius` | `'none' \| 'small' \| 'medium' \| 'large' \| 'full'` | `'medium'` | Border radius scale |
| `scaling` | `number` | `1` | Overall scaling factor (1 = 100%) |
| `panelBackground` | `'solid' \| 'translucent'` | `'solid'` | Panel background style |
#### Runtime Behavior
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `appearance` | `'light' \| 'dark' \| 'inherit'` | `'inherit'` | Color scheme preference. Use 'inherit' to follow device/parent settings |
| `forcedMode` | `'light' \| 'dark'` | `undefined` | Force a specific mode, overriding device and parent settings |
| `hasBackground` | `boolean` | `true` | Whether to apply background color |
| `onModeChange` | `(mode: 'light' \| 'dark') => void` | `undefined` | Callback when theme mode changes |
#### Legacy Support
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `themeOptions` | `Partial` | `undefined` | Theme options object (legacy - use flat props instead). Flat props take precedence |
#### Toast Configuration
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `toastConfig` | `ToastConfig` | `undefined` | Configuration options for toast notifications |
### Available Accent Colors
`amber`, `blue`, `bronze`, `brown`, `crimson`, `cyan`, `gold`, `grass`, `green`, `indigo`, `iris`, `jade`, `lime`, `mint`, `orange`, `pink`, `plum`, `purple`, `red`, `ruby`, `sky`, `teal`, `tomato`, `violet`, `yellow`
### Gray Scale Variants
`gray`, `mauve`, `olive`, `sage`, `sand`, `slate`
---
## Hooks
### useTheme
Returns the current theme object.
```tsx
const theme = useTheme();
// Returns: Theme object with colors, typography, spacing, etc.
```
### useThemeMode
Returns the current theme mode.
```tsx
const mode = useThemeMode();
// Returns: 'light' | 'dark'
```
### useThemeActions
Returns theme actions and current mode.
```tsx
const { setMode, toggleMode, mode } = useThemeActions();
// setMode: (mode: ThemeMode) => void
// toggleMode: () => void
// mode: ThemeMode
```
---
## Components
### Layout Components
#### Box
Primitive container with styling props.
```tsx
Content
```
#### Flex
Flexbox layout component.
```tsx
Left
Right
```
**Props:**
- `direction`: `'row' | 'column' | 'row-reverse' | 'column-reverse'`
- `align`: `'start' | 'center' | 'end' | 'stretch' | 'baseline'`
- `justify`: `'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'`
- `wrap`: `'wrap' | 'nowrap' | 'wrap-reverse'`
- `gap`: `number` (uses theme scale)
#### Grid
Grid layout component.
```tsx
Item 1
Item 2
Item 3
```
#### Container
Responsive container with max-width.
```tsx
Content
```
#### Inset
Padding component with overflow clipping.
```tsx
```
---
### Typography Components
#### Text
```tsx
Text content
```
**Props:**
- `size`: `1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9` (default: 3)
- `weight`: `'light' | 'regular' | 'medium' | 'bold'`
- `align`: `'left' | 'center' | 'right'`
- `color`: `string`
- `truncate`: `boolean`
#### Heading
```tsx
Heading
```
**Props:**
- `size`: `1 | 2 | 3 | 4 | 5` (default: 3)
- `weight`: `'light' | 'regular' | 'medium' | 'bold'`
#### Strong, Em, Code, Kbd
```tsx
Bold text
Italic text
const x = 42;
Cmd + C
```
---
### Form Components
#### Button
```tsx
```
**Props:**
- `variant`: `'classic' | 'solid' | 'soft' | 'outline' | 'ghost'` (default: 'classic')
- `size`: `1 | 2 | 3` (default: 2)
- `color`: `string` (accent color name)
- `disabled`: `boolean`
- `loading`: `boolean`
- `highContrast`: `boolean`
- `onPress`: `(event: GestureResponderEvent) => void`
- `width`: `number | string`
#### TextField
```tsx
```
**Props:**
- `value`: `string`
- `onChangeText`: `(text: string) => void`
- `placeholder`: `string`
- `variant`: `'classic' | 'surface' | 'soft'`
- `size`: `1 | 2 | 3`
- `disabled`: `boolean`
- `error`: `string`
- `secureTextEntry`: `boolean`
#### Checkbox
```tsx
```
#### Switch
```tsx
```
#### RadioGroup
```tsx
Option 1
Option 2
```
#### Select
```tsx
```
#### Slider
```tsx
```
---
### Data Display Components
#### Avatar
```tsx
```
#### Badge
```tsx
Active
```
**Props:**
- `variant`: `'solid' | 'soft' | 'outline'`
- `size`: `1 | 2 | 3`
- `color`: `string`
- `highContrast`: `boolean`
#### Card
```tsx
Card content
```
**Props:**
- `variant`: `'elevated' | 'outlined' | 'flat'`
- `size`: `1 | 2 | 3`
#### Progress
```tsx
```
#### Spinner
```tsx
```
---
### Overlay Components
#### Dialog
```tsx
Dialog Title
Dialog description
```
#### AlertDialog
```tsx
Confirm Delete
Are you sure you want to delete this item?
```
#### Popover
```tsx
Popover content
```
#### Tooltip
```tsx
} />
Tooltip text
```
#### DropdownMenu
```tsx
Edit
Copy
Delete
```
#### Toast
```tsx
// Using the toast hook
import { useToast } from 'radix-native-ui';
function MyComponent() {
const { toast } = useToast();
return (
);
}
```
---
### Disclosure Components
#### Accordion
```tsx
First Item
Content for first item
Second Item
Content for second item
```
**Accordion.Root Props:**
- `type`: `'single' | 'multiple'` (required)
- `value`: `string | string[]` (controlled)
- `defaultValue`: `string | string[]`
- `onValueChange`: `(value: string | string[]) => void`
- `collapsible`: `boolean` (for single type)
- `disabled`: `boolean`
- `size`: `'1' | '2' | '3'`
---
### Utility Components
#### AspectRatio
```tsx
```
#### ScrollArea
```tsx
{items.map(item => (
{item.name}
))}
```
#### VisuallyHidden
```tsx
Screen reader only text
```
---
## Color Scale Structure
Each color has a 12-step scale:
| Step | Purpose |
|------|---------|
| 1 | App background |
| 2 | Subtle background |
| 3 | UI element background |
| 4 | Hovered UI element background |
| 5 | Active / Selected UI element background |
| 6 | Subtle borders |
| 7 | UI element border, focus ring |
| 8 | Hovered UI element border |
| 9 | Solid backgrounds |
| 10 | Hovered solid backgrounds |
| 11 | Low-contrast text |
| 12 | High-contrast text |
---
## Spacing Scale
| Step | Value |
|------|-------|
| 0 | 0px |
| 1 | 4px |
| 2 | 8px |
| 3 | 12px |
| 4 | 16px |
| 5 | 20px |
| 6 | 24px |
| 7 | 32px |
| 8 | 40px |
| 9 | 48px |
| 10 | 64px |
| 11 | 80px |
| 12 | 96px |
| 13 | 128px |
---
## Typography Scale
| Size | Font Size | Line Height |
|------|-----------|-------------|
| 1 | 11px | 16px |
| 2 | 12px | 18px |
| 3 | 14px | 20px |
| 4 | 16px | 24px |
| 5 | 18px | 26px |
| 6 | 20px | 28px |
| 7 | 24px | 32px |
| 8 | 30px | 36px |
| 9 | 36px | 40px |
---
## Migration from Web Radix Themes
| Web | React Native |
|-----|--------------|
| `onClick` | `onPress` |
| `onChange` | `onChangeText` / `onValueChange` |
| CSS properties | StyleSheet props |
| CSS variables | Theme context values |
```tsx
// Web
// React Native
```
---
## Links
- **GitHub**: https://github.com/Copy-Labs/radix-ui-native-kilo
- **npm**: https://www.npmjs.com/package/radix-native-ui
- **Original Radix Themes**: https://www.radix-ui.com/themes