Introduction
Tailor is a powerful library for creating styled React components with Tailwind CSS in an organized and typed way. It provides a simple and intuitive API for managing component styles, variants, and responsive design while maintaining full TypeScript support.
Features
- 🎨 Type-safe styling with TypeScript
- 🎯 Smart class merging for efficient style management
- 📱 Responsive design support out of the box
- 🎭 Dynamic class generation based on props
- 🎪 Nested styles for complex components
- 🎬 Animation support for interactive components
Installation
npm install @dennerrondinely/tailor
# or
yarn add @dennerrondinely/tailor
# or
pnpm add @dennerrondinely/tailor
Quick Start
Here's a simple example of how to use Tailor to create a styled button component:
import { craft } from '@dennerrondinely/tailor';
interface ButtonProps {
isActive?: boolean;
disabled?: boolean;
children: React.ReactNode;
}
const Button: React.FC<ButtonProps> = ({ children, ...props }) => (
<button {...props}>{children}</button>
);
const StyledButton = craft(Button)({
base: 'px-4 py-2 rounded font-medium transition-colors',
dynamic: {
'bg-blue-500 text-white': (props) => !props.isActive,
'bg-green-500 text-white': (props) => props.isActive,
'hover:opacity-90': (props) => !props.disabled,
'active:scale-95': (props) => !props.disabled,
'disabled:opacity-50 disabled:cursor-not-allowed': (props) => props.disabled
},
responsive: {
sm: 'text-sm',
md: 'text-base',
lg: 'text-lg'
}
});
// Usage
<StyledButton isActive={true}>Click me</StyledButton>
Why Tailor?
Tailor was created to solve common challenges when working with Tailwind CSS in React applications:
- Type Safety: Get full TypeScript support for your component props and styles
- Organization: Keep your component styles organized and maintainable
- Reusability: Create reusable styled components with consistent behavior
- Performance: Optimize your bundle size with smart class merging
- Developer Experience: Enjoy a great developer experience with intuitive APIs
Next Steps
- Check out the API Reference for detailed documentation
- Learn about Advanced Usage for complex components
- Explore Examples to see Tailor in action
- Join our GitHub Discussions to share your ideas and get help