code-architecture-tailwind-v4-best-practices

Guide Tailwind CSS v4 component styling with CSS-first configuration and variant abstraction strategies.

Updated Nov 28, 2025
One-click install
npx skills add https://github.com/davidsteinberger/dotfiles --skill code-architecture-tailwind-v4-best-practices-davidsteinberger
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/davidsteinberger/dotfiles/tree/main/opencode/.config/opencode/skills/code-architecture-tailwind-v4-best-practices
Command: npx skills add https://github.com/davidsteinberger/dotfiles --skill code-architecture-tailwind-v4-best-practices-davidsteinberger

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear guidance on the best practices for structuring and styling components using Tailwind CSS v4, helping developers adopt its CSS-first approach effectively.

Core Features & Use Cases

  • CSS-First Configuration: Understand Tailwind v4's new configuration model using @theme.
  • Abstraction Strategies: Learn when to use pure utilities, CVA, or tailwind-variants for component variants.
  • State Management: Implement state management using native data attributes.
  • Use Case: When building a new component library with Tailwind v4, use this Skill to decide the optimal way to handle variants and ensure accessibility.

Quick Start

Follow the guidance in this Skill to implement a button component using Tailwind v4 best practices.

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 configure Tailwind CSS v4 using the new CSS-first approach?

Tailwind CSS v4 configuration uses a CSS-first approach through the @theme directive, replacing traditional JavaScript config files to define design tokens directly in your stylesheets for component architecture.

What is the best way to handle component variants in Tailwind v4?

Handling component variants in Tailwind v4 involves choosing between direct utility usage, CVA, or tailwind-variants, depending on your abstraction needs and component complexity for optimal styling patterns.

How do I manage component state with data attributes in Tailwind CSS?

Managing component state with data attributes in Tailwind CSS involves applying native data attributes to handle variants and interactions directly within your CSS-first configuration for accessible component architecture.

Should I use CVA or tailwind-variants for my Tailwind CSS component library?

Choosing between CVA and tailwind-variants for a Tailwind CSS component library depends on your specific abstraction strategies, variant complexity, and desired state management configuration approach.

When should I use direct utility classes instead of component abstractions in Tailwind v4?

Direct utility classes in Tailwind v4 are recommended for simpler styling needs, while component abstractions like CVA or tailwind-variants are better for managing complex component variants and state.

Does Tailwind CSS v4 work well for building accessible component libraries?

Tailwind CSS v4 supports building accessible component libraries by utilizing CSS-first configuration, native data attributes for state management, and structured abstraction strategies for component variants.