ever-co/ever-works / .agents/skills/tailwind-css-patterns
tailwind-css-patterns
VerifiedProvides comprehensive Tailwind CSS utility-first styling patterns including responsive design, layout utilities, flexbox, grid, spacing, typography, colors, and modern CSS best practices. Use when styling React/Vue/Svelte components, building responsive layouts, implementing design systems, or optimizing CSS workflow.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.2 KB |
| references/accessibility.md | markdown | 3.9 KB |
| references/animations.md | markdown | 3.3 KB |
| references/component-patterns.md | markdown | 4.4 KB |
| references/configuration.md | markdown | 3.0 KB |
| references/layout-patterns.md | markdown | 3.7 KB |
| references/performance.md | markdown | 2.4 KB |
| references/reference.md | markdown | 9.7 KB |
| references/responsive-design.md | markdown | 3.6 KB |
references/performance.md
View on GitHub# Tailwind CSS Performance Optimization
## Bundle Size Optimization
Configure content sources for optimal purging:
```javascript
// tailwind.config.js
export default {
content: [
'./index.html',
'./src/**/*.{js,ts,jsx,tsx,vue,svelte}',
'./node_modules/@mycompany/ui-lib/**/*.{js,ts,jsx,tsx}'
],
// Enable JIT for faster builds
jit: true
};
```
### Content Path Best Practices
1. **Be specific**: Don't use `"./**/*"` - it scans too many files
2. **Include UI libraries**: Add paths to component libraries
3. **Exclude tests**: Don't include test files in content paths
---
## CSS Optimization Techniques
```html
<!-- Use content-visibility for offscreen content -->
<div class="content-visibility-auto">
<div>Heavy content that's initially offscreen</div>
</div>
<!-- Optimize images with aspect-ratio -->
<img class="aspect-video w-full object-cover" src="video.jpg" alt="Video thumbnail" />
<!-- Use contain for paint optimization -->
<div class="contain-layout">Complex layout that doesn't affect outside elements</div>
```
---
## Development Performance (v4.1+)
```css
/* Enable CSS-first configuration in v4.1 */
@import 'tailwindcss';
@theme {
/* Define once, use everywhere */
--color-brand: #3b82f6;
--font-mono: 'Fira Code', monospace;
}
/* Critical CSS for above-the-fold content */
@layer critical {
.hero-title {
@apply text-4xl md:text-6xl font-bold;
}
}
```
---
## Production Build Optimization
### PurgeCSS Configuration
```javascript
// tailwind.config.js
module.exports = {
purge: {
enabled: process.env.NODE_ENV === 'production',
content: ['./src/**/*.html', './src/**/*.jsx', './src/**/*.tsx'],
options: {
safelist: [
'bg-red-500',
'text-center'
// Classes that shouldn't be purged
]
}
}
};
```
### Minification
```bash
# Use cssnano for minification
npm install -D cssnano
# In postcss.config.js
module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
...(process.env.NODE_ENV === 'production' ? [require('cssnano')] : []),
],
}
```
---
## Best Practices for Performance
1. **Use the JIT engine**: Faster builds, smaller output
2. **Configure content correctly**: Only include files that use Tailwind
3. **Minimize custom CSS**: Use Tailwind utilities over custom CSS
4. **Enable purging in production**: Removes unused styles
5. **Use `@layer` for custom styles**: Helps with organization and purging
6. **Avoid `@apply` in components**: Prefer composing utilities in markup
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |