Full TypeScript Support
Every component is fully typed with:- Generic props for flexible type inference
- Polymorphic components via the
asprop - Strict type checking for render props
- Exported type definitions for custom compositions
Type Inference
Components automatically infer types from your data:Carousel Type Inference
The Carousel component uses generics to infer image types:carousel.tsx
types.ts
Generic Component Props
For Component
TheFor component uses generics to maintain type safety:
for.tsx
Show Component
TheShow component narrows types based on the when condition:
show.tsx
PolymorphicProps Pattern
Components usePolymorphicProps to support custom HTML elements via the as prop:
card.tsx
PolymorphicPropsStrict
Some components usePolymorphicPropsStrict for stricter type checking:
form.tsx
Real Type Signatures
Card Component Types
Carousel Component Types
Form Component Types
Type Exports
You can import and use component types for custom compositions:Benefits
Autocomplete
Get intelligent autocomplete for all props, including valid HTML attributes for the rendered element.
Type Safety
Catch errors at compile time, not runtime. Invalid props are flagged immediately.
Refactoring
Rename properties, change types, or restructure data - TypeScript keeps you safe.
Documentation
Types serve as inline documentation. Hover over any prop to see its type and description.
Advanced Patterns
Discriminated Unions
Some components use discriminated unions for flexible APIs:Render Prop Type Safety
Next Steps
Component Structure
Understand compound component patterns
Styling
Learn how to style type-safe components