Use when building reusable component patterns with Tailwind CSS. Covers component extraction, @apply directive, and composable design patterns.
View on GitHubTheBushidoCollective/han
jutsu-tailwind
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-tailwind/skills/tailwind-components/SKILL.md -a claude-code --skill tailwind-componentsInstallation paths:
.claude/skills/tailwind-components/# Tailwind CSS - Component Patterns
While Tailwind is utility-first, you'll often want to extract common patterns into reusable components. This skill covers strategies for building maintainable component architectures with Tailwind.
## Key Concepts
### Component Extraction Strategies
There are several approaches to creating reusable components with Tailwind:
1. **Template/Component Abstraction** (Recommended)
2. **CSS `@apply` Directive** (Use sparingly)
3. **JavaScript/TypeScript Component Classes**
4. **Tailwind Plugins**
### Template Component Abstraction
The most maintainable approach is to extract components at the template level:
```jsx
// Button.tsx
interface ButtonProps {
variant?: 'primary' | 'secondary' | 'outline'
size?: 'sm' | 'md' | 'lg'
children: React.ReactNode
onClick?: () => void
}
export function Button({
variant = 'primary',
size = 'md',
children,
onClick
}: ButtonProps) {
const baseClasses = 'font-semibold rounded transition-colors focus:ring-2 focus:ring-offset-2'
const variantClasses = {
primary: 'bg-blue-500 hover:bg-blue-600 text-white focus:ring-blue-300',
secondary: 'bg-gray-500 hover:bg-gray-600 text-white focus:ring-gray-300',
outline: 'border-2 border-blue-500 text-blue-500 hover:bg-blue-50 focus:ring-blue-300',
}
const sizeClasses = {
sm: 'px-3 py-1.5 text-sm',
md: 'px-4 py-2 text-base',
lg: 'px-6 py-3 text-lg',
}
return (
<button
className={`${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]}`}
onClick={onClick}
>
{children}
</button>
)
}
```
## Best Practices
### 1. Use Class Variance Authority (CVA)
For complex component variants, use `cva` for better type safety:
```typescript
import { cva, type VariantProps } from 'class-variance-authority'
const button = cva(
// Base classes
'font-semibold rounded transition-colors focus:ring-2',
{
variants: {
intent: {
primary: 'bg-blue-500 hover:bg-blue-600 tex