Build accessible design systems with Radix UI primitives. Headless component customization, theming strategies, and compound component patterns for production-grade UI libraries.
Add this skill
npx mdskills install sickn33/radix-ui-design-systemComprehensive guide with clear patterns, theming strategies, and accessibility focus for building Radix UI design systems
Build production-ready, accessible design systems using Radix UI primitives with full customization control and zero style opinions.
Radix UI provides unstyled, accessible components (primitives) that you can customize to match any design system. This skill guides you through building scalable component libraries with Radix UI, focusing on accessibility-first design, theming architecture, and composable patterns.
Key Strengths:
Every Radix primitive is built with accessibility as the foundation:
Rule: Never override accessibility features. Enhance, don't replace.
Radix provides behavior, you provide appearance:
// ❌ Don't fight pre-styled components
// ✅ Radix gives you behavior, you add styling
Build complex components from simple primitives:
// Primitive components compose naturally
Tab 1
Tab 2
Content 1
Content 2
# Install individual primitives (recommended)
npm install @radix-ui/react-dialog @radix-ui/react-dropdown-menu
# Or install multiple at once
npm install @radix-ui/react-{dialog,dropdown-menu,tabs,tooltip}
# For styling (optional but common)
npm install clsx tailwind-merge class-variance-authority
Every Radix component follows this pattern:
import * as Dialog from '@radix-ui/react-dialog';
export function MyDialog() {
return (
{/* Trigger the dialog */}
Open
{/* Portal renders outside DOM hierarchy */}
{/* Overlay (backdrop) */}
{/* Content (modal) */}
Title
Description
{/* Your content here */}
Close
);
}
Best for: Maximum portability, SSR-friendly
/* globals.css */
:root {
--color-primary: 220 90% 56%;
--color-surface: 0 0% 100%;
--radius-base: 0.5rem;
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}
[data-theme="dark"] {
--color-primary: 220 90% 66%;
--color-surface: 222 47% 11%;
}
// Component.tsx
Best for: Tailwind projects, variant-heavy components
// button.tsx
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/lib/utils';
const buttonVariants = cva(
// Base styles
"inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline: "border border-input bg-background hover:bg-accent",
ghost: "hover:bg-accent hover:text-accent-foreground",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
);
interface ButtonProps extends VariantProps {
children: React.ReactNode;
}
export function Button({ variant, size, children }: ButtonProps) {
return (
{children}
);
}
Best for: Runtime theming, scoped styles
import { styled } from '@stitches/react';
import * as Dialog from '@radix-ui/react-dialog';
const StyledContent = styled(Dialog.Content, {
backgroundColor: '$surface',
borderRadius: '$md',
padding: '$6',
variants: {
size: {
small: { width: '300px' },
medium: { width: '500px' },
large: { width: '700px' },
},
},
defaultVariants: {
size: 'medium',
},
});
Use case: Share state between primitive parts
// Select.tsx
import * as Select from '@radix-ui/react-select';
import { CheckIcon, ChevronDownIcon } from '@radix-ui/react-icons';
export function CustomSelect({ items, placeholder, onValueChange }) {
return (
{items.map((item) => (
{item.label}
))}
);
}
asChildUse case: Render as different elements without losing behavior
// ✅ Render as Next.js Link but keep Radix behavior
Open Settings
// ✅ Render as custom component
}>Action
Why asChild matters: Prevents nested button/link issues in accessibility tree.
// Uncontrolled (Radix manages state)
Tab 1
// Controlled (You manage state)
const [activeTab, setActiveTab] = useState('tab1');
Tab 1
Rule: Use controlled when you need to sync with external state (URL, Redux, etc.).
import * as Dialog from '@radix-ui/react-dialog';
import { motion, AnimatePresence } from 'framer-motion';
export function AnimatedDialog({ open, onOpenChange }) {
return (
{open && (
<>
{/* Content */}
)}
);
}
{/* State container */}
{/* Opens dialog */}
{/* Renders in portal */}
{/* Backdrop */}
{/* Modal content */}
{/* Required for a11y */}
{/* Required for a11y */}
{/* Closes dialog */}
{/* Nested menus */}
Tooltip text
Content
aria-invalid and aria-describedbyaria-busy during async operationsDialog.Title is present (required for screen readers)Dialog.Description provides contextAlways use asChild to avoid wrapper divs
Open
Provide semantic HTML
{/* content */}
Use CSS variables for theming
.dialog-content {
background: hsl(var(--surface));
color: hsl(var(--on-surface));
}
Compose primitives for complex components
function CommandPalette() {
return (
{/* Radix Combobox inside Dialog */}
);
}
Don't skip accessibility parts
// ❌ Missing Title and Description
Content
Don't fight the primitives
// ❌ Overriding internal behavior
e.stopPropagation()}>
Don't mix controlled and uncontrolled
// ❌ Inconsistent state management
Don't ignore keyboard navigation
// ❌ Disabling keyboard behavior
e.preventDefault()}>
import * as Dialog from '@radix-ui/react-dialog';
import { Command } from 'cmdk';
export function CommandPalette() {
const [open, setOpen] = useState(false);
useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
setOpen((open) => !open);
}
};
document.addEventListener('keydown', down);
return () => document.removeEventListener('keydown', down);
}, []);
return (
No results found.
Calendar
Search Emoji
);
}
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
import { DotsHorizontalIcon } from '@radix-ui/react-icons';
export function ActionsMenu() {
return (
Edit
Duplicate
Delete
);
}
import * as Select from '@radix-ui/react-select';
import { useForm, Controller } from 'react-hook-form';
interface FormData {
country: string;
}
export function CountryForm() {
const { control, handleSubmit } = useForm();
return (
console.log(data))}>
(
United States
Canada
United Kingdom
)}
/>
Submit
);
}
Cause: onEscapeKeyDown event prevented or open state not synced
Solution:
{/* Don't prevent default on escape */}
Cause: Parent container has overflow: hidden or transform
Solution:
// Use Portal to render outside overflow container
Cause: Portal content unmounts immediately
Solution:
// Use forceMount + AnimatePresence
{open && }
asChildCause: Type inference issues with polymorphic components
Solution:
// Explicitly type your component
Open
// Lazy load heavy primitives
const Dialog = lazy(() => import('@radix-ui/react-dialog'));
const DropdownMenu = lazy(() => import('@radix-ui/react-dropdown-menu'));
// Create portal container once
{/* All tooltips share portal container */}
...
...
// Memoize expensive render functions
const SelectItems = memo(({ items }) => (
items.map((item) => )
));
shadcn/ui is a collection of copy-paste components built with Radix + Tailwind.
npx shadcn-ui@latest init
npx shadcn-ui@latest add dialog
When to use shadcn vs raw Radix:
import { Theme, Button, Dialog } from '@radix-ui/themes';
function App() {
return (
Click me
);
}
@tailwind-design-system - Tailwind + Radix integration patterns@react-patterns - React composition patterns@frontend-design - Overall frontend architecture@accessibility-compliance - WCAG compliance testingnpm install @radix-ui/react-{primitive-name}
asChild - Render as child elementdefaultValue - Uncontrolled defaultvalue / onValueChange - Controlled stateopen / onOpenChange - Open stateside / align - PositioningRemember: Radix gives you behavior, you give it beauty. Accessibility is built-in, customization is unlimited.
Install via CLI
npx mdskills install sickn33/radix-ui-design-systemRadix UI Design System is a free, open-source AI agent skill. Build accessible design systems with Radix UI primitives. Headless component customization, theming strategies, and compound component patterns for production-grade UI libraries.
Install Radix UI Design System with a single command:
npx mdskills install sickn33/radix-ui-design-systemThis downloads the skill files into your project and your AI agent picks them up automatically.
Radix UI Design System works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Codex, Gemini Cli, Amp, Roo Code, Goose, Opencode, Trae, Qodo, Command Code. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.