code-architecture-tailwind-v4-best-practices

Guide Tailwind CSS v4 adoption with CSS-first configuration and abstraction strategies.

5|Updated Oct 17, 2011
One-click install
npx skills add https://github.com/klen/dotfiles --skill code-architecture-tailwind-v4-best-practices-klen
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/klen/dotfiles/tree/main/.config/opencode/skills/code-architecture-tailwind-v4-best-practices
Command: npx skills add https://github.com/klen/dotfiles --skill code-architecture-tailwind-v4-best-practices-klen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear guidance on adopting Tailwind CSS v4's modern CSS-first approach, helping developers choose the right abstraction strategy for components and avoid common pitfalls.

Core Features & Use Cases

  • CSS-First Configuration: Understand Tailwind v4's new configuration via @theme.
  • Abstraction Strategies: Learn when to use pure utilities, CVA, or tailwind-variants based on component complexity and variant count.
  • State Management: Implement stateful styling using data attributes.
  • Use Case: You're starting a new project with Tailwind v4 and need to decide whether to abstract your button component with CVA or stick to pure utilities. This skill will guide your decision.

Quick Start

Consult the decision matrix to determine the best abstraction strategy for your component.

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 uses a CSS-first configuration approach via the `@theme` directive, replacing the traditional JavaScript config file. This modern setup allows you to define your design tokens directly in your CSS.

When should I use CVA versus tailwind-variants for component abstraction in Tailwind v4?

You should choose between CVA and tailwind-variants based on your component complexity and variant count. A decision matrix helps determine the right abstraction strategy, guiding when to use pure utilities or abstraction libraries for optimal component architecture.

What are the main changes when migrating from Tailwind CSS v3 to v4?

The main changes from Tailwind v3 to v4 involve shifting to a CSS-first configuration using `@theme` and adopting new component abstraction strategies. The transition focuses on modern CSS patterns and updated state management techniques for frontend styling.

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

You can implement stateful styling in Tailwind CSS by using data attributes. This approach allows you to manage component state directly within your CSS, providing a clean way to handle variants and interactive states without heavy JavaScript dependencies.

Should I stick to pure utilities or use an abstraction library for my Tailwind components?

Deciding whether to use pure utilities or an abstraction library depends on your component's complexity and variant count. For simple components, pure utilities suffice, while complex components benefit from CVA or tailwind-variants for maintainable component architecture.