Requirements
Recast requires React 17 or later and works with any CSS framework or styling solution.
Install the package
Choose your preferred package manager:Basic usage
Import Recast and start creating styled components:Global configuration (optional)
For advanced use cases, you can configure Recast globally:Configuration options
function
default:"Built-in merger"
Custom function for merging class names. Popular options include
clsx, classnames, or tailwind-merge.boolean
default:"false"
Enable performance monitoring in development mode. Logs cache hit rates and computation times.
number
default:"200"
Maximum number of entries in the LRU cache. Increase for better performance with many style variations.
Framework integration
Tailwind CSS
Recast works perfectly with Tailwind CSS out of the box:CSS Modules
Recast also works with CSS Modules:Styled Components
You can even use Recast with CSS-in-JS solutions:TypeScript support
Recast includes comprehensive TypeScript definitions out of the box. All style definitions, variants, and modifiers are fully typed, providing excellent autocomplete and type safety:Nested component support
For complex components with multiple parts, Recast provides special type helpers to ensure type safety across all component parts:Verification
To verify your installation is working correctly:1
Create a test component
2
Use the component
3
Check the output
The component should render with the correct classes applied.
“px-4 py-2 rounded font-medium bg-blue-500 text-white”