code-architecture-tailwind-v4-best-practices

Guide component architecture decisions for Tailwind CSS v4 projects.

Updated Apr 17, 2026
One-click install
npx skills add https://github.com/Chris-Maskey/opencode-config --skill code-architecture-tailwind-v4-best-practices-chris-maskey
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-architecture-tailwind-v4-best-practices
Source: https://github.com/Chris-Maskey/opencode-config/tree/main/skills/code-architecture-tailwind-v4-best-practices
Command: npx skills add https://github.com/Chris-Maskey/opencode-config --skill code-architecture-tailwind-v4-best-practices-chris-maskey

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides clear, actionable guidance for structuring components and choosing abstraction patterns when using Tailwind CSS v4, removing uncertainty about when to use raw utilities versus CVA or tailwind-variants and how to adopt the CSS-first @theme approach.

Core Features & Use Cases

  • CSS-first configuration: Explains how to use @theme for design tokens and the v4 build improvements.
  • Abstraction guidance: Decision thresholds for using pure utilities, CVA, or tailwind-variants based on variant count, type safety, bundle cost, and multi-part components.
  • Patterns & accessibility: Examples and checklist for accessible interactive elements, data-attribute state, and modern React component patterns (shadcn/ui style).
  • Migration & compatibility: Highlights breaking changes from v3 and recommended migration steps and tooling.

Quick Start

Recommend whether to use pure utilities, CVA, or tailwind-variants for a responsive button component with primary and size variants.

Frequently Asked Questions about code-architecture-tailwind-v4-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure Tailwind v4 components using CSS-first @theme tokens?

Structure Tailwind v4 components by defining design tokens within the @theme directive, leveraging the CSS-first configuration approach to replace legacy JavaScript config files and ensure consistent styling across your application.

When should I use tailwind-variants vs CVA for React component design?

Use tailwind-variants or CVA for React component design when variant counts grow, requiring type-safe variant management and clear threshold evaluation to balance bundle cost and multi-part component abstraction over pure utilities.

How do I manage data-attribute state for accessible Tailwind components?

Manage data-attribute state for accessible Tailwind components by applying data attributes to handle interactive states, following modern patterns like shadcn/ui to ensure compliance with accessibility checks and robust state management.

What are the Tailwind v4 breaking changes I need to fix during migration?

Tailwind v4 breaking changes during migration involve shifting to CSS-first @theme configuration, updating token definitions, and adjusting tooling to accommodate the new build improvements and configuration syntax.

What's the best way to handle responsive variants in Tailwind CSS v4?

The best way to handle responsive variants in Tailwind CSS v4 is evaluating variant counts and responsive needs against bundle cost trade-offs, choosing between pure utilities, CVA, or tailwind-variants for optimal component architecture.