```
## Common Patterns
### Alert with Close
```jsx
const [showAlert, setShowAlert] = useState(true);
{showAlert && (
SuccessOperation completed
)}
```
### Button Group
```jsx
```
### Status Badge
```jsx
ActiveOnline
```
### Loading State
```jsx
import LoadingSpinner from '../components/LoadingSpinner';
{isLoading && }
{isLoading && }
```
### Empty State
```jsx
No items found
Create one to get started
```
## Responsive Patterns
### Mobile First
```jsx
// Base style for mobile, override on larger screens
className="flex flex-col md:flex-row"
className="text-sm md:text-base lg:text-lg"
className="w-full md:w-1/2 lg:w-1/3"
className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3"
```
### Show/Hide on Breakpoint
```jsx
className="hidden md:block" // show on medium and up
className="md:hidden" // hide on medium and up
className="block lg:hidden" // show except on large
```
## Performance Tips
1. **Use Tailwind for styling**, not inline styles
2. **Keep components small** and focused
3. **Use `className` merging** with `cn()` function for dynamic classes
4. **Avoid unused Tailwind classes** - Tailwind purges them in production
5. **Use semantic HTML** with proper heading hierarchy
6. **Lazy load components** when possible
## Common Issues & Solutions
### Issue: Styles not applying
**Solution**: Ensure:
- Tailwind is configured correctly in `tailwind.config.js`
- CSS is imported in `index.css` with `@tailwind` directives
- PostCSS is configured in `postcss.config.js`
### Issue: Colors not matching
**Solution**:
- Check CSS variables in `:root` of `index.css`
- Verify Tailwind config has extended colors
- Use exact class names: `text-text-primary` not `text-primary`
### Issue: Component not styled
**Solution**:
- Verify component is imported from `/lib/ui`
- Check `cn()` utility merges classes correctly
- Ensure parent has proper `className` applied
## Migration Checklist for New Pages
When creating or refactoring a page:
- [ ] Use ShadCN Button for all actions
- [ ] Use ShadCN Card for content grouping
- [ ] Use ShadCN Alert for notifications
- [ ] Use ShadCN Dialog for modals
- [ ] Use ShadCN Input for form fields
- [ ] Use ShadCN Badge for status indicators
- [ ] Use Tailwind grid for layouts
- [ ] Use Tailwind for spacing and sizing
- [ ] Use custom CSS variables for colors
- [ ] Follow mobile-first responsive design
- [ ] Test on mobile, tablet, and desktop
---
**Last Updated**: November 6, 2025