Syntax
Configuration object defining the styles, variants, modifiers, and defaults
RecastStylesObject - A style object that can be applied to components or used to extract class names
Configuration Properties
Foundation classes applied to all instances.
Mutually exclusive styling options.
Boolean flags that can be combined.
Default values to reduce prop repetition.
Apply styles only when specific conditions are met.
Return Value
The style object provides two main capabilities:Component Application
Apply styles to any React component:Style Extraction
Extract computed class names for advanced use cases:TypeScript Integration
Recast automatically generates TypeScript types:Performance
Automatic Memoization
All style computations are cached for fast repeated access
LRU Cache
Prevents memory leaks with configurable cache size limits
Best Practices
Semantic Naming
Use meaningful names like
variant and size rather than generic namesSet Defaults
Define sensible defaults to reduce prop repetition
Single Responsibility
Keep each style object focused on one concern
Compose Ready
Design styles to work well with
recast.compose()