How radix-ui/primitives works
Main Components Structure
A. Core Layer
• Primitive, number, and rect packages
B. React Components Layer
• Above the core layer
• Components into logical groups:
• Navigation (Menubar, NavigationMenu, Tabs)
• Overlay (Dialog, Popover, Toast, Tooltip)
• Form Controls (Checkbox, Radio, Select, Switch)
• Layout (AspectRatio, ScrollArea, Separator)
• Utility (Portal, Presence, VisuallyHidden)
C. Hooks Layer
• As a side section
• Custom hooks (useCallbackRef, useControllableState, etc.)
• To components that utilize them
Component Relationships
• Dependencies between components
• Composition patterns
• Shared utilities
→ Direct dependencies
⇢ Composition relationships
⇄ Two-way interactions
Infrastructure Elements
Supporting systems:
• Storybook integration
• Testing infrastructure (Cypress)
• SSR testing setup
• Build system
Key Technical Aspects to Highlight
A. Accessibility Features
• To relevant components
B. State Management
• State flow between controlled and uncontrolled components
• Context providers
C. Portal System
• Demonstrate portal architecture
• Relationship with overlay components
Implementation Details
Use specific visual elements:
┌─────────────────┐
• Component Group │
• ┘
⚡ Core Primitives
🔄 State Management
🎯 Event Handlers
🔒 Accessibility Features