Type Exports
Each component package exports TypeScript types for all its parts:Component Type Inference
Radix components useReact.forwardRef with proper typing. You can infer element types using React’s utility types:
Extending Component Props
You can extend Radix component props to create your own typed components:Generic Props
Some components like Accordion have discriminated union types for their props:The
type prop determines the types of value, defaultValue, and the onValueChange callback parameter.Controlled vs Uncontrolled Types
Radix components support both controlled and uncontrolled usage with appropriate types:Ref Types
All Radix components properly forward refs with correct types:Primitive Component Types
Radix uses aPrimitive component system. Each primitive extends native HTML element props:
Type-Safe Event Handlers
Event handlers maintain proper types:Creating Wrapper Libraries
Build type-safe wrapper components:1
Define base component types
2
Extend with custom props
3
Create typed component
AsChild Prop Type
TheasChild prop allows component composition with proper typing:
When using
asChild, the Radix component merges its props with the child component’s props.