### Install Radix Icons package
Source: https://github.com/radix-ui/icons/blob/main/packages/radix-icons/README.md
Use npm to add the Radix Icons library to your project dependencies.
```bash
npm install @radix-ui/react-icons
```
--------------------------------
### Navigation Icons in React
Source: https://context7.com/radix-ui/icons/llms.txt
Illustrates the usage of various navigation-related icons from Radix Icons, such as arrows, chevrons, and carets. Examples include their use in pagination controls, breadcrumb separators, sortable table headers, and dropdown triggers.
```tsx
import {
ArrowLeftIcon,
ArrowRightIcon,
ArrowUpIcon,
ArrowDownIcon,
ChevronLeftIcon,
ChevronRightIcon,
ChevronUpIcon,
ChevronDownIcon,
DoubleArrowLeftIcon,
DoubleArrowRightIcon,
CaretDownIcon,
CaretSortIcon,
} from "@radix-ui/react-icons";
function NavigationDemo() {
return (
);
}
```
--------------------------------
### IconProps Interface and Ref Forwarding
Source: https://context7.com/radix-ui/icons/llms.txt
Details the `IconProps` interface, which extends standard SVG attributes and includes a `color` prop. Shows an example of using `React.forwardRef` to access and manipulate the SVG element of an icon, such as applying a transform on click.
```tsx
import type * as React from "react";
interface IconProps extends React.SVGAttributes {
children?: never; // Icons do not accept children
color?: string; // Defaults to "currentColor"
}
// Usage with ref forwarding
import { useRef } from "react";
import { StarIcon } from "@radix-ui/react-icons";
function RefExample() {
const iconRef = useRef(null);
const handleClick = () => {
if (iconRef.current) {
iconRef.current.style.transform = "scale(1.2)";
}
};
return (
);
}
```
--------------------------------
### Generate icon library from Figma
Source: https://github.com/radix-ui/icons/blob/main/packages/generate-icon-lib/README.md
Executes the CLI tool using a specific Figma file key.
```shell
generate-icon-lib --file=
```
--------------------------------
### Generate Icon Library
Source: https://github.com/radix-ui/icons/blob/main/packages/radix-icons/CONTRIBUTING.md
Run this command to generate the icon library after making changes to Figma files or CLI code. Ensure your Figma access token is set in the .env file.
```bash
pnpm generate-src
```
--------------------------------
### Configure Figma access token
Source: https://github.com/radix-ui/icons/blob/main/packages/generate-icon-lib/README.md
Saves the Figma personal access token to an environment file for authentication.
```shell
echo "FIGMA_ACCESS_TOKEN=" >> packages/radix-icons/.env
```
--------------------------------
### Basic Icon Usage in React
Source: https://context7.com/radix-ui/icons/llms.txt
Demonstrates how to import and use individual Radix Icons components in a React application. Icons can inherit color from their parent or be customized using the `color` prop. Size can be adjusted via `width` and `height` props, and standard SVG attributes can be applied.
```tsx
import { FaceIcon, SunIcon, MoonIcon, GearIcon } from "@radix-ui/react-icons";
function IconDemo() {
return (
{/* Basic usage - inherits color from parent */}
{/* Custom color */}
{/* Custom size via width/height props */}
{/* With additional SVG attributes */}
console.log("Settings clicked")}
/>
);
}
```
--------------------------------
### Implement Action Toolbar with Icons
Source: https://context7.com/radix-ui/icons/llms.txt
Use action icons like Plus, Pencil, Copy, Trash, MagnifyingGlass, and Gear for interactive elements in a toolbar. The TrashIcon can be styled with a danger color.
```tsx
import {
PlusIcon,
MinusIcon,
Cross1Icon,
Cross2Icon,
CheckIcon,
TrashIcon,
Pencil1Icon,
CopyIcon,
DownloadIcon,
UploadIcon,
ReloadIcon,
MagnifyingGlassIcon,
GearIcon,
} from "@radix-ui/react-icons";
function ActionToolbar() {
return (
{/* Add button */}
{/* Edit button */}
{/* Copy button */}
{/* Delete button with danger color */}
{/* Search input with icon */}
{/* Settings */}
{/* Refresh */}
);
}
```
--------------------------------
### Create Media Player Controls with Icons
Source: https://context7.com/radix-ui/icons/llms.txt
Integrate media control icons like Play, Pause, Shuffle, TrackPrevious, TrackNext, and Loop for audio/video players. Volume control can be managed using Speaker icons that change based on volume level.
```tsx
import {
PlayIcon,
PauseIcon,
StopIcon,
ResumeIcon,
TrackPreviousIcon,
TrackNextIcon,
LoopIcon,
ShuffleIcon,
SpeakerLoudIcon,
SpeakerModerateIcon,
SpeakerQuietIcon,
SpeakerOffIcon,
} from "@radix-ui/react-icons";
function MediaPlayer() {
const [isPlaying, setIsPlaying] = useState(false);
const [volume, setVolume] = useState(75);
const VolumeIcon = volume === 0 ? SpeakerOffIcon
: volume < 33 ? SpeakerQuietIcon
: volume < 66 ? SpeakerModerateIcon
: SpeakerLoudIcon;
return (
{/* Playback controls */}
{/* Volume control */}
setVolume(Number(e.target.value))}
/>
);
}
```
--------------------------------
### Individual Icon Imports
Source: https://context7.com/radix-ui/icons/llms.txt
Import icons individually from their specific module paths to optimize bundle size. This approach is recommended for tree-shaking and reducing the final application footprint.
```tsx
// Named imports from main package (tree-shakeable)
import { HomeIcon, GearIcon, PersonIcon } from "@radix-ui/react-icons";
// Individual file imports (alternative approach)
import HomeIcon from "@radix-ui/react-icons/HomeIcon";
import GearIcon from "@radix-ui/react-icons/GearIcon";
import PersonIcon from "@radix-ui/react-icons/PersonIcon";
function App() {
return (
);
}
```
--------------------------------
### Complete Icon Categories Reference
Source: https://context7.com/radix-ui/icons/llms.txt
This snippet demonstrates importing multiple icons from various categories like Arrows, UI Components, File/Document, Communication, Data/Charts, and Device Icons. Use these imports to access a wide range of icons for your application.
```tsx
// Arrows and Navigation
import {
ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, ArrowDownIcon,
ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomLeftIcon, ArrowBottomRightIcon,
ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon,
DoubleArrowLeftIcon, DoubleArrowRightIcon, DoubleArrowUpIcon, DoubleArrowDownIcon,
ThickArrowLeftIcon, ThickArrowRightIcon, ThickArrowUpIcon, ThickArrowDownIcon,
TriangleLeftIcon, TriangleRightIcon, TriangleUpIcon, TriangleDownIcon,
CaretLeftIcon, CaretRightIcon, CaretUpIcon, CaretDownIcon, CaretSortIcon,
} from "@radix-ui/react-icons";
// UI Components
import {
ButtonIcon, InputIcon, SliderIcon, SwitchIcon, CheckboxIcon,
RadiobuttonIcon, DropdownMenuIcon, AvatarIcon, BadgeIcon,
} from "@radix-ui/react-icons";
// File and Document
import {
FileIcon, FileTextIcon, FilePlusIcon, FileMinusIcon,
ReaderIcon, ClipboardIcon, ClipboardCopyIcon,
} from "@radix-ui/react-icons";
// Communication
import {
EnvelopeClosedIcon, EnvelopeOpenIcon, ChatBubbleIcon,
PaperPlaneIcon, BellIcon,
} from "@radix-ui/react-icons";
// Data and Charts
import {
BarChartIcon, PieChartIcon, ActivityLogIcon, DashboardIcon,
TableIcon, CalendarIcon,
} from "@radix-ui/react-icons";
// Device Icons
import {
DesktopIcon, LaptopIcon, MobileIcon, KeyboardIcon,
CameraIcon, VideoIcon,
} from "@radix-ui/react-icons";
```
--------------------------------
### Import and use Radix Icons in React
Source: https://github.com/radix-ui/icons/blob/main/packages/radix-icons/README.md
Import specific icon components from the library and render them within your JSX.
```js
import { FaceIcon, ImageIcon, SunIcon } from "@radix-ui/react-icons";
function MyComponent() {
return (
);
}
```
--------------------------------
### Theme Toggle Icons
Source: https://context7.com/radix-ui/icons/llms.txt
Use SunIcon and MoonIcon for implementing dark/light mode toggles. Ensure proper styling for button appearance and icon color based on the theme state.
```tsx
import { SunIcon, MoonIcon } from "@radix-ui/react-icons";
import { useState } from "react";
function ThemeToggle() {
const [isDark, setIsDark] = useState(false);
return (
);
}
```
--------------------------------
### Interactive State Icons
Source: https://context7.com/radix-ui/icons/llms.txt
Implement toggleable states like favorites, bookmarks, and visibility using paired filled and outlined icons. Manage state with useState and conditionally render icons based on the state.
```tsx
import {
StarIcon,
StarFilledIcon,
HeartIcon,
HeartFilledIcon,
BookmarkIcon,
BookmarkFilledIcon,
EyeOpenIcon,
EyeClosedIcon,
LockClosedIcon,
LockOpen1Icon,
} from "@radix-ui/react-icons";
import { useState } from "react";
function InteractiveIcons() {
const [isFavorite, setIsFavorite] = useState(false);
const [isLiked, setIsLiked] = useState(false);
const [isBookmarked, setIsBookmarked] = useState(false);
const [isVisible, setIsVisible] = useState(true);
const [isLocked, setIsLocked] = useState(true);
return (
);
}
```
--------------------------------
### Display Layout and Design Icons
Source: https://context7.com/radix-ui/icons/llms.txt
Use these icons for layout controls, spacing adjustments, and design tools within an interface. Ensure icons are imported from '@radix-ui/react-icons'.
```tsx
import {
LayoutIcon,
GridIcon,
ColumnsIcon,
RowsIcon,
LayersIcon,
FrameIcon,
BoxModelIcon,
MarginIcon,
PaddingIcon,
DimensionsIcon,
AspectRatioIcon,
ZoomInIcon,
ZoomOutIcon,
GroupIcon,
} from "@radix-ui/react-icons";
function DesignToolbar() {
return (
{/* Layout options */}
{/* Layer controls */}
{/* Spacing controls */}
{/* Sizing controls */}
);
}
```
--------------------------------
### Display Text and Typography Icons
Source: https://context7.com/radix-ui/icons/llms.txt
These icons are useful for text formatting and typography controls in rich text editors. Import them from '@radix-ui/react-icons'.
```tsx
import {
FontBoldIcon,
FontItalicIcon,
UnderlineIcon,
StrikethroughIcon,
TextAlignLeftIcon,
TextAlignCenterIcon,
TextAlignRightIcon,
TextAlignJustifyIcon,
HeadingIcon,
FontSizeIcon,
LetterCaseUppercaseIcon,
ListBulletIcon,
QuoteIcon,
CodeIcon,
} from "@radix-ui/react-icons";
function TextEditor() {
return (
{/* Text style group */}
{/* Alignment group */}
{/* Block elements */}
);
}
```
--------------------------------
### Display Brand and Logo Icons
Source: https://context7.com/radix-ui/icons/llms.txt
Use these icons to represent popular platforms and services in social links or branding elements. Ensure the icons are imported from '@radix-ui/react-icons'.
```tsx
import {
GitHubLogoIcon,
TwitterLogoIcon,
LinkedInLogoIcon,
InstagramLogoIcon,
DiscordLogoIcon,
FigmaLogoIcon,
VercelLogoIcon,
CodeSandboxLogoIcon,
NotionLogoIcon,
} from "@radix-ui/react-icons";
function SocialLinks() {
return (
);
}
function DeveloperTools() {
return (
Built with:
);
}
```
--------------------------------
### Display Status Messages with Icons
Source: https://context7.com/radix-ui/icons/llms.txt
Utilize status icons such as CheckCircledIcon, CrossCircledIcon, ExclamationTriangleIcon, and InfoCircledIcon to convey success, error, warning, or informational messages. A QuestionMarkCircledIcon can be used for help tooltips.
```tsx
import {
CheckCircledIcon,
CrossCircledIcon,
ExclamationTriangleIcon,
InfoCircledIcon,
QuestionMarkCircledIcon,
} from "@radix-ui/react-icons";
function StatusMessages() {
return (
{/* Success message */}
Operation completed successfully
{/* Error message */}
An error occurred
{/* Warning message */}
Please review before continuing
{/* Info message */}
Here's some helpful information
{/* Help tooltip trigger */}
);
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.