tailwind-css-patterns
giuseppe-trisciuoglio/developer-kit
Utility-first Tailwind CSS patterns for responsive, accessible component styling.
What is tailwind-css-patterns?
Provides comprehensive Tailwind CSS v4.1+ patterns for building responsive layouts, design systems, and modern UIs. Use when styling React/Vue/Svelte components, implementing dark mode, or optimizing CSS workflow with utility-first best practices.
- Mobile-first responsive design with breakpoint prefixes (sm, md, lg, xl, 2xl)
- Flexbox and grid layout utilities for complex component structures
- Dark mode support with class or media strategy toggle
- Component extraction patterns for reusable styled elements
- Design token composition using spacing, color, and typography scales
- Accessibility features including focus states, ARIA labels, and motion preferences
How to install tailwind-css-patterns
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill tailwind-css-patterns- Tailwind CSS v4.1 or later installed
- Content paths configured in tailwind.config.js to include all template files
- Node.js and npm for build tooling
How to use tailwind-css-patterns
- 1.Write base styles for mobile screens without responsive prefixes
- 2.Add responsive prefixes (sm:, md:, lg:) for larger breakpoints using DevTools responsive mode
- 3.Compose multiple utilities together for complex styles instead of using @apply
- 4.Extract repeated patterns into reusable component classes or functions
- 5.Configure custom design tokens in tailwind.config.js or using @theme directive
- 6.Test at each breakpoint and verify accessibility before committing changes
Use cases
- Building responsive card components that adapt from mobile to desktop layouts
- Implementing dark mode toggle functionality across entire application
- Creating form inputs with focus states and validation styling
- Designing responsive grid layouts for product listings or dashboards
- Extracting repeated styling patterns into reusable component classes
- React/Vue/Svelte component developers
- UI/UX engineers building design systems
- Frontend developers optimizing CSS workflow
- Teams implementing responsive, accessible interfaces
tailwind-css-patterns FAQ
Check that all template files are included in the content array in tailwind.config.js. Run npm run build to regenerate the CSS, and use npx tailwindcss -o --watch for live updates during development.
Set darkMode: 'class' or 'media' in tailwind.config.js. For class strategy, toggle the 'dark' class on the html element using document.documentElement.classList.toggle('dark'). Use dark: prefix on utilities to apply dark mode styles.
Prefer composing utility classes directly in your markup for better maintainability. Use @apply only for extracting repeated patterns into component classes, not for complex selectors.
Write base styles for mobile screens first, then add responsive prefixes (sm:, md:, lg:) for larger screens. This ensures your design works on all devices and improves performance.
Modify the theme object in tailwind.config.js to customize spacing, colors, typography, and breakpoints. Alternatively, use the CSS-first @theme directive in your CSS file for simpler configurations.
Full instructions (SKILL.md)
Source of truth, from giuseppe-trisciuoglio/developer-kit.
name: tailwind-css-patterns description: Provides 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. allowed-tools: Read, Write, Edit, Glob, Grep, Bash
Tailwind CSS Development Patterns
Expert guide for building modern, responsive user interfaces with Tailwind CSS utility-first framework. Covers v4.1+ features including CSS-first configuration, custom utilities, and enhanced developer experience.
Overview
Provides actionable patterns for responsive, accessible UIs with Tailwind CSS v4.1+. Covers utility composition, dark mode, component patterns, and performance optimization.
When to Use
- Styling React/Vue/Svelte components
- Building responsive layouts and grids
- Implementing design systems
- Adding dark mode support
- Optimizing CSS workflow
Quick Reference
Responsive Breakpoints
| Prefix | Min Width | Description |
|---|---|---|
sm: | 640px | Small screens |
md: | 768px | Tablets |
lg: | 1024px | Desktops |
xl: | 1280px | Large screens |
2xl: | 1536px | Extra large |
Common Patterns
<!-- Center content -->
<div class="flex items-center justify-center min-h-screen">
Content
</div>
<!-- Responsive grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
<!-- Items -->
</div>
<!-- Card component -->
<div class="bg-white rounded-lg shadow-lg p-6">
<h3 class="text-xl font-bold">Title</h3>
<p class="text-gray-600">Description</p>
</div>
Instructions
- Start Mobile-First: Write base styles for mobile, add responsive prefixes (
sm:,md:,lg:) for larger screens - Use Design Tokens: Leverage Tailwind's spacing, color, and typography scales
- Compose Utilities: Combine multiple utilities for complex styles
- Extract Components: Create reusable component classes for repeated patterns
- Configure Theme: Customize design tokens in
tailwind.config.jsor using@theme - Verify Changes: Test at each breakpoint using DevTools responsive mode. Check for visual regressions and accessibility issues before committing.
Examples
Responsive Card Component
function ProductCard({ product }: { product: Product }) {
return (
<div className="bg-white rounded-lg shadow-lg overflow-hidden sm:flex">
<img className="h-48 w-full object-cover sm:h-auto sm:w-48" src={product.image} />
<div className="p-6">
<h3 className="text-lg font-semibold">{product.name}</h3>
<button className="mt-4 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">
Add to Cart
</button>
</div>
</div>
);
}
Dark Mode Toggle
<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
<h1 class="dark:text-white">Title</h1>
</div>
Form Input
<input
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="you@example.com"
/>
Best Practices
- Consistent Spacing: Use Tailwind's spacing scale (4, 8, 12, 16, etc.)
- Color Palette: Stick to Tailwind's color system for consistency
- Component Extraction: Extract repeated patterns into reusable components
- Utility Composition: Prefer utility classes over
@applyfor maintainability - Semantic HTML: Use proper HTML elements with Tailwind classes
- Performance: Ensure content paths include all template files for optimal purging
- Accessibility: Include focus styles, ARIA labels, and respect user preferences (reduced-motion)
Troubleshooting
Classes Not Applying
- Check content paths: Ensure all template files are included in
content: []in config - Verify build: Run
npm run buildto regenerate purged CSS - Dev mode: Use
npx tailwindcss -owith--watchflag for live updates
Responsive Styles Not Working
- Order matters: Responsive prefixes must come before non-responsive (e.g.,
md:flexnotflex md:flex) - Check breakpoint values: Verify breakpoints match your design requirements
- DevTools: Use browser DevTools responsive mode to test at each breakpoint
Dark Mode Issues
- Verify config: Ensure
darkMode: 'class'or'media'is set correctly - Toggle implementation: Use
document.documentElement.classList.toggle('dark')for class strategy - Initial flash: Add
darkclass to<html>before body renders
Constraints and Warnings
- Class Proliferation: Long class strings reduce readability; extract into components
- Content Paths: Misconfigured paths cause classes to be purged in production
- Arbitrary Values: Use sparingly; prefer design tokens for consistency
- Specificity Issues: Avoid
@applywith complex selectors - Dark Mode: Requires correct configuration (
classormediastrategy) - Browser Support: Check Tailwind docs for compatibility notes
References
- references/layout-patterns.md — Flexbox, grid, spacing, typography, colors
- references/component-patterns.md — Cards, navigation, forms, modals, React patterns
- references/responsive-design.md — Responsive patterns, dark mode, container queries
- references/animations.md — Transitions, transforms, built-in animations, motion preferences
- references/performance.md — Bundle optimization, CSS optimization, production builds
- references/accessibility.md — Focus management, screen readers, color contrast, ARIA
- references/configuration.md — CSS-first config, JavaScript config, plugins, presets
- references/reference.md — Additional reference materials
External Resources
Related skills
More from giuseppe-trisciuoglio/developer-kit and the wider catalog.

tailwind-design-system
Build consistent UI component libraries with Tailwind CSS v4.1+ and shadcn/ui design tokens.

turborepo-monorepo
Comprehensive Turborepo monorepo management for TypeScript/JavaScript projects with workspace setup, task configuration, and CI/CD optimization.

typescript-docs
Generate production-ready TypeScript documentation with JSDoc, TypeDoc, and ADRs for multiple audiences.

typescript-security-review
Security audit for TypeScript/Node.js apps: XSS, injection, CSRF, JWT, CVEs, secrets exposure.

unit-test-application-events
Unit test patterns for Spring ApplicationEvent publishers and @EventListener consumers without booting the full context.

unit-test-bean-validation
Unit test Jakarta Bean Validation constraints and custom validators with JUnit 5 in isolation.