### Install Radix Primitives
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/overview/getting-started.mdx
Install Radix Primitives from your command line using npm.
```bash
npm install radix-ui@latest
```
--------------------------------
### Install Radix Themes using bun
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/overview/getting-started.mdx
Install the Radix Themes package using bun. This is a fast, all-in-one JavaScript runtime.
```bash
bun add @radix-ui/themes
```
--------------------------------
### Basic Tabs Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/tabs.mdx
A fundamental example demonstrating the structure of the Tabs component with triggers and content sections. Use this as a starting point for implementing tabs.
```jsx
AccountDocumentsSettingsMake changes to your account.Access and update your documents.Edit your profile or update contact information.
```
--------------------------------
### Install Radix UI Package
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/overview/introduction.mdx
Install the main radix-ui package to import primitives. This is recommended to prevent version conflicts and manage updates.
```bash
npm install radix-ui
```
--------------------------------
### Install Individual Radix Primitives
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/overview/introduction.mdx
Alternatively, install each primitive individually using its scoped package name. This allows for more granular control over dependencies.
```bash
npm install @radix-ui/react-dialog
npm install @radix-ui/react-dropdown-menu
npm install @radix-ui/react-tooltip
```
--------------------------------
### Basic Callout Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/callout.mdx
A basic example of the Callout component with an icon and text. This is useful for general information or tips.
```jsx
You will need admin privileges to install and access this application.
```
--------------------------------
### Slider Size Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/slider.mdx
Demonstrates how to control the size of the Slider using the `size` prop.
```jsx
```
--------------------------------
### Dropdown Menu Usage Example
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/dropdown-menu.mdx
Demonstrates how to use a custom Dropdown Menu component. This example shows the import and rendering of various menu items, labels, groups, checkboxes, radio buttons, and separators.
```jsx
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuItem,
DropdownMenuGroup,
DropdownMenuCheckboxItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
} from "./your-dropdown-menu";
export default () => (
DropdownMenu triggerItemLabelGroupCheckboxItemSeparatorRadioItemRadioItem
);
```
--------------------------------
### Basic Flex Layout Example
Source: https://github.com/radix-ui/website/blob/main/data/blog/themes-3.mdx
Demonstrates a simple Flex layout component with a fixed width.
```jsx
```
--------------------------------
### Responsive Grid Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/grid.mdx
Demonstrates how to use breakpoint objects with props like `columns` and `rows` to create responsive grid layouts.
```APIDOC
## Responsive Grid
All props marked `Responsive`, such as `columns` and `rows` accept a [breakpoint object](/themes/docs/theme/breakpoints). For example, the following grid starts with 1 column, and uses 2 columns from the medium breakpoint.
### Example Usage
```jsx
```
### Props Used
- **columns**: Accepts a breakpoint object. `initial` sets the default, `md` applies from the medium breakpoint onwards.
- **gap**: Standard gap property.
- **width**: Standard width property.
```
--------------------------------
### Install Radix Themes using npm
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/overview/getting-started.mdx
Install the Radix Themes package using npm. This is the first step to integrating the component library into your project.
```bash
npm install @radix-ui/themes
```
--------------------------------
### Install Radix Themes using yarn
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/overview/getting-started.mdx
Install the Radix Themes package using yarn. This is an alternative to npm for package management.
```bash
yarn add @radix-ui/themes
```
--------------------------------
### Basic Alert Dialog Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/alert-dialog.mdx
This example demonstrates a basic alert dialog with a trigger button, title, description, cancel button, and action button. Use this for standard confirmation flows.
```jsx
Revoke access
Are you sure? This application will no longer be accessible and any
existing sessions will be expired.
```
--------------------------------
### Basic Checkbox Cards Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/checkbox-cards.mdx
Demonstrates the basic usage of CheckboxCards.Root with multiple items. Use this to create a group of selectable cards.
```jsx
A1 KeyboardUS LayoutPro MouseZero-lag wirelessLightning MatWireless charging
```
--------------------------------
### Basic Button Usage
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/button.mdx
A basic example of using the Button component with an icon and text.
```jsx
```
--------------------------------
### Install Radix Themes using pnpm
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/overview/getting-started.mdx
Install the Radix Themes package using pnpm. This is another package manager option.
```bash
pnpm add @radix-ui/themes
```
--------------------------------
### Card Sizing Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/card.mdx
Illustrates different `size` prop values for the Card component, affecting its overall dimensions and spacing.
```jsx
Teodros Girmay
Engineering
Teodros Girmay
Engineering
Teodros Girmay
Engineering
```
--------------------------------
### Vertical Tabs Example
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/tabs.mdx
Demonstrates how to create vertical tabs using the `orientation` prop. Ensure the Tabs component is imported from 'radix-ui'.
```jsx
import { Tabs } from "radix-ui";
export default () => (
OneTwoThreeTab one contentTab two contentTab three content
);
```
--------------------------------
### Progress Component Example
Source: https://github.com/radix-ui/website/blob/main/data/blog/themes-3.mdx
Illustrates the usage of the Progress component for indicating task progress or indeterminate loading states.
```jsx
```
--------------------------------
### Slider Radius Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/slider.mdx
Shows how to set the border radius of the Slider using the `radius` prop.
```jsx
```
--------------------------------
### Tab Navigation Component Example
Source: https://github.com/radix-ui/website/blob/main/data/blog/themes-3.mdx
Shows how to use the Tab Nav component for navigating between views, built on the Navigation Menu primitive for accessibility.
```jsx
```
--------------------------------
### Slider High-Contrast Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/slider.mdx
Demonstrates the `highContrast` prop for increased color contrast in light mode.
```jsx
```
--------------------------------
### Basic Code Snippet
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/code.mdx
A simple example of the Code component displaying a console log statement.
```jsx
console.log()
```
--------------------------------
### Vertical Slider Example
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/slider.mdx
Demonstrates how to create a vertical slider using the `orientation` prop. Includes JSX and CSS for styling.
```jsx
import { Slider } from "radix-ui";
import "./styles.css";
export default () => (
);
```
```css
/* styles.css */
.SliderRoot {
position: relative;
display: flex;
align-items: center;
}
.SliderRoot[__data-orientation="vertical"__] {
flex-direction: column;
width: 20px;
height: 100px;
}
.SliderTrack {
position: relative;
flex-grow: 1;
background-color: grey;
}
.SliderTrack[__data-orientation="vertical"__] {
width: 3px;
}
.SliderRange {
position: absolute;
background-color: black;
}
.SliderRange[__data-orientation="vertical"__] {
width: 100%;
}
.SliderThumb {
display: block;
width: 20px;
height: 20px;
background-color: black;
}
```
--------------------------------
### Basic Grid Layout
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/grid.mdx
A basic example of a Grid component with 3 columns and 2 rows, each row having a fixed height.
```jsx
```
--------------------------------
### Menubar Anatomy
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/menubar.mdx
Import all Menubar parts and assemble them to create the component structure. This example demonstrates the basic anatomy and available sub-components.
```jsx
import { Menubar } from "radix-ui";
export default () => (
);
```
--------------------------------
### Run Development Server
Source: https://github.com/radix-ui/website/blob/main/README.md
Use this command to start the development server for the Radix UI website. Open http://localhost:3000 in your browser to view the result.
```bash
pnpm dev
```
--------------------------------
### Slider Range Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/slider.mdx
An example of a Slider component configured to select a range of values.
```jsx
```
--------------------------------
### Controlled Context Menu Example
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/overview/releases.mdx
Demonstrates how to use the controlled `open` prop on `ContextMenu.Root` to manage the open state programmatically. This is useful for reading the state and closing the menu, but opening it programmatically is discouraged.
```tsx
function ControlledContextMenu() {
const [open, setOpen] = React.useState(false);
return (
OpenItem 1Item 2
);
}
```
--------------------------------
### Basic Radio Cards Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/radio-cards.mdx
Demonstrates the basic structure of Radio Cards with multiple items. Use the `defaultValue` prop to set the initially selected card and `columns` to control the layout.
```jsx
8-core CPU32 GB RAM6-core CPU24 GB RAM4-core CPU16 GB RAM
```
--------------------------------
### Install Radix Colors with npm, yarn, or pnpm
Source: https://github.com/radix-ui/website/blob/main/data/colors/docs/overview/installation.mdx
Install Radix Colors from your terminal using your preferred package manager. The current version is 3.0.0.
```bash
# with npm
npm install @radix-ui/colors
# with yarn
yarn add @radix-ui/colors
# with pnpm
pnpm add @radix-ui/colors
```
--------------------------------
### Basic Hover Card Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/hover-card.mdx
This is a basic example of a Hover Card component. It wraps a link with the HoverCard.Root and HoverCard.Trigger, and displays content in HoverCard.Content when hovered.
```jsx
Follow{" "}
@radix_ui
Radix
@radix_ui
React components, icons, and colors for building high-quality,
accessible UI.
{" "}
for updates.
```
--------------------------------
### Checkbox Indeterminate State Example
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/checkbox.mdx
Demonstrates how to set a checkbox to an indeterminate state by controlling its state. This example includes a button to toggle between indeterminate and checked states.
```jsx
import { DividerHorizontalIcon, CheckIcon } from "@radix-ui/react-icons";
import { Checkbox } from "radix-ui";
export default () => {
const [checked, setChecked] = React.useState("indeterminate");
return (
<>
{checked === "indeterminate" && }
{checked === true && }
>
);
};
```
--------------------------------
### Basic Scroll Area Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/scroll-area.mdx
A basic example of a Scroll Area with vertical scrollbars, demonstrating its use with content that exceeds the container height. Use this for standard scrollable content.
```jsx
Principles of the typographic craft
Three fundamental aspects of typography are legibility, readability, and
aesthetics. Although in a non-technical sense “legible” and “readable”
are often used synonymously, typographically they are separate but
related concepts.
Legibility describes how easily individual characters can be
distinguished from one another. It is described by Walter Tracy as “the
quality of being decipherable and recognisable”. For instance, if a “b”
and an “h”, or a “3” and an “8”, are difficult to distinguish at small
sizes, this is a problem of legibility.
Typographers are concerned with legibility insofar as it is their job to
select the correct font to use. Brush Script is an example of a font
containing many characters that might be difficult to distinguish. The
selection of cases influences the legibility of typography because using
only uppercase letters (all-caps) reduces legibility.
```
--------------------------------
### Basic Radio Group Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/radio-group.mdx
A basic example of a Radio Group with three selectable items. Use this to create a standard radio button selection interface where only one option can be chosen.
```jsx
DefaultComfortableCompact
```
--------------------------------
### Basic Container Usage
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/container.mdx
Demonstrates how to use the Container component with a specific size. This example shows a Container with size '1' wrapped in a Box for styling.
```jsx
```
--------------------------------
### Applying Color Scale Steps to Text
Source: https://github.com/radix-ui/website/blob/main/data/colors/docs/palette-composition/understanding-the-scale.mdx
Demonstrates how to use color scale steps 11 and 12 for text elements. Step 11 is for low-contrast text, and step 12 is for high-contrast text.
```jsx
import { Flex, Text } from '@radix-ui/themes';
function App() {
return (
This text is Pink 11
This text is Slate 11
This text is Gray 11
This text is Pink 12
This text is Slate 12
This text is Gray 12
);
}
```
--------------------------------
### Heading Text Trimming (Start) with Text Trimming (End)
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/heading.mdx
Applies 'trim="start"' to the heading and 'trim="end"' to a Text component to demonstrate trimming leading space for better vertical spacing in boxed layouts.
```jsx
Without trim
The goal of typography is to relate font size, line height, and line width
in a proportional way that maximizes beauty and makes reading easier and
more pleasant.
With trim
The goal of typography is to relate font size, line height, and line width
in a proportional way that maximizes beauty and makes reading easier and
more pleasant.
```
--------------------------------
### Basic Context Menu Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/context-menu.mdx
Demonstrates a basic context menu with various item types including submenus and separators. This is typically triggered by a right-click or long press on the trigger element.
```jsx
EditDuplicateArchiveMoreMove to project…Move to folder…Advanced options…ShareAdd to favorites
Delete
```
--------------------------------
### Basic Link
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/link.mdx
A basic example of a Link component used for navigation.
```jsx
Sign up
```
--------------------------------
### Blockquote Basic Usage
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/blockquote.mdx
A basic example of the Blockquote component displaying a quotation.
```jsx
Perfect typography is certainly the most elusive of all arts. Sculpture in
stone alone comes near it in obstinacy.
```
--------------------------------
### Basic Dropdown Menu Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/dropdown-menu.mdx
Demonstrates a standard dropdown menu with various item types, including submenus and separators. Use this for common action menus triggered by a button.
```jsx
EditDuplicateArchiveMoreMove to project…Move to folder…Advanced options…ShareAdd to favorites
Delete
```
--------------------------------
### Basic Dialog Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/dialog.mdx
Demonstrates a typical dialog with a trigger button, title, description, form fields, and action buttons. Use this for standard modal interactions.
```jsx
Edit profile
Make changes to your profile.
```
--------------------------------
### Create Custom Toast API (Usage)
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/toast.mdx
Demonstrates how to use a custom Toast component by abstracting primitive parts. Ensure the custom Toast component is correctly imported.
```jsx
import { Toast } from "./your-toast";
export default () => (
);
```
--------------------------------
### Basic Checkbox Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/checkbox.mdx
A simple checkbox integrated with text, demonstrating its basic usage.
```jsx
Agree to Terms and Conditions
```
--------------------------------
### Import and Basic Structure
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/toolbar.mdx
Import the Toolbar component and demonstrate its basic structure with various child elements like buttons, separators, links, and toggle groups.
```jsx
import { Toolbar } from "radix-ui";
export default () => (
);
```
--------------------------------
### Toast with Alternative Action for Screen Readers
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/toast.mdx
Shows how to use the `altText` prop on `Toast.Action` to provide screen reader-specific instructions for an action. Includes examples for both background and foreground toasts with custom durations.
```jsx
Upgrade Available!We've just released Radix 1.0.
Upgrade
DismissFile removed successfully.
Undo Alt+UDismiss
```
--------------------------------
### Slider Color Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/slider.mdx
Illustrates applying different colors to the Slider using the `color` prop.
```jsx
```
--------------------------------
### Slider Variant Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/slider.mdx
Shows different visual styles for the Slider using the `variant` prop.
```jsx
```
--------------------------------
### Responsive Flex Layout with Object Syntax
Source: https://github.com/radix-ui/website/blob/main/data/blog/themes-3.mdx
Illustrates using responsive object syntax to define different widths for a Flex layout at various breakpoints (initial, sm, md).
```jsx
```
--------------------------------
### Basic Aspect Ratio Usage
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/aspect-ratio.mdx
Use the AspectRatio component to wrap your content and specify the desired ratio. This example demonstrates a 16:8 ratio with an image.
```jsx
```
--------------------------------
### Menubar with Checkbox Items
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/components/menubar.mdx
Demonstrates how to implement checkbox items in a Menubar using `Menubar.CheckboxItem` and managing their checked state.
```jsx
import * as React from "react";
import { CheckIcon } from "@radix-ui/react-icons";
import { Menubar } from "radix-ui";
export default () => {
const [checked, setChecked] = React.useState(true);
return (
………
Checkbox item
);
};
```
--------------------------------
### Basic Progress Bar
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/progress.mdx
A simple Progress component displayed within a Box. This is a basic usage example.
```jsx
```
--------------------------------
### Import Slot Component
Source: https://github.com/radix-ui/website/blob/main/data/primitives/docs/utilities/slot.mdx
Import the Slot component from the radix-ui library. This is the initial setup for using Slot.
```jsx
import { Slot } from "radix-ui";
export default () => (
Hello
);
```
--------------------------------
### RadioGroup High Contrast Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/radio-group.mdx
Increase color contrast with the background by using the `highContrast` prop. This is useful for accessibility.
```jsx
```
--------------------------------
### Default Cursors Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/theme/cursors.mdx
Demonstrates the default cursor appearances for various interactive elements like buttons, links, checkboxes, and switches, including disabled states.
```jsx
Link
```
--------------------------------
### RadioGroup Size Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/radio-group.mdx
Control the size of the radio buttons using the `size` prop. Multiple sizes are available.
```jsx
```
--------------------------------
### Basic Kbd Usage
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/kbd.mdx
Renders a basic keyboard input element.
```jsx
Shift + Tab
```
--------------------------------
### Truncate Link Text
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/link.mdx
Example of truncating link text with an ellipsis when it overflows its container, using the `truncate` prop.
```jsx
Sign up to the newsletter
```
--------------------------------
### Card Variant Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/card.mdx
Shows the different visual styles available for the Card component using the `variant` prop.
```jsx
Quick start
Start building your next project in minutes
Quick start
Start building your next project in minutes
```
--------------------------------
### Using Radix Colors with vanilla-extract
Source: https://github.com/radix-ui/website/blob/main/data/colors/docs/overview/usage.mdx
Import color scales and use vanilla-extract's createTheme to define themes. Colors are then accessed via variables within styles.
```javascript
import {
gray,
blue,
red,
green,
grayDark,
blueDark,
redDark,
greenDark,
} from "@radix-ui/colors";
import { createTheme } from "@vanilla-extract/css";
export const [theme, vars] = createTheme({
colors: {
...gray,
...blue,
...red,
...green,
},
});
export const darkTheme = createTheme(vars, {
colors: {
...grayDark,
...blueDark,
...redDark,
...greenDark,
},
});
// Use the colors in your styles
export const styles = {
button: style({
backgroundColor: vars.colors.blue4,
color: vars.colors.blue11,
borderColor: vars.colors.blue7,
":hover": {
backgroundColor: vars.colors.blue5,
borderColor: vars.colors.blue8,
},
}),
};
// Apply your theme to it
export default function App() {
return (
);
}
```
--------------------------------
### Basic Data List Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/data-list.mdx
Demonstrates a typical usage of the DataList component to display various types of information like status, ID, name, email, and company. Includes interactive elements like a copy button and links.
```jsx
Status
Authorized
IDu_2J89JSA4GJNameVlad MorozEmail
vlad@workos.com
Company
WorkOS
```
--------------------------------
### RadioGroup Color Examples
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/radio-group.mdx
Apply a specific color to the radio buttons using the `color` prop. A variety of colors are supported.
```jsx
```
--------------------------------
### Basic Popover Example
Source: https://github.com/radix-ui/website/blob/main/data/themes/docs/components/popover.mdx
A standard popover with a button trigger and content including a text area and comment button. This demonstrates the core structure of a popover.
```jsx
Send to group
```