code-architecture-tailwind-v4-best-practices

Guide Tailwind CSS v4 component development with CSS-first tokens and variant strategies.

Updated Apr 26, 2026
One-click install
npx skills add https://github.com/suwandre/my-opencode-config --skill code-architecture-tailwind-v4-best-practices-suwandre
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/suwandre/my-opencode-config/tree/main/skills/code-architecture-tailwind-v4-best-practices
Command: npx skills add https://github.com/suwandre/my-opencode-config --skill code-architecture-tailwind-v4-best-practices-suwandre

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Streamline building consistent UI components with Tailwind CSS v4 by clarifying when to use primitive utilities versus higher-level abstractions like CVA or Tailwind-variants, and by detailing a CSS-first workflow.

Core Features & Use Cases

  • Clear guidance on using utilities directly in markup for simple components.
  • Guidance on CVA and Tailwind-variants for 3+ variants and complex component libraries.
  • Tailwind v4 CSS-first approach with @theme design tokens and CSS variables for design consistency.
  • Practical patterns for common UI elements like buttons and cards across React, Vue, and vanilla projects.

Quick Start

Instantiate a simple Tailwind v4 button using utilities in markup, and escalate to a CVA-based variant when 3+ variants are needed.

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

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

FAQPage Schema
When should I use CVA vs Tailwind-variants for component design?

Use CVA or Tailwind-variants when building complex component libraries with 3 or more variants. For simple UI components, apply Tailwind v4 utilities directly in markup to avoid premature abstraction and keep code maintainable.

How do I use Tailwind v4 CSS-first workflow with @theme tokens?

The Tailwind v4 CSS-first workflow uses @theme design tokens and CSS variables to establish design consistency. Define your tokens in CSS, reference them as utilities, and let the compiler generate the necessary styles for your components.

Can I apply these Tailwind v4 patterns across React, Vue, and vanilla projects?

Yes, these Tailwind CSS v4 patterns apply across React, Vue, and vanilla projects. The guidance covers practical implementations for common UI elements like buttons and cards, ensuring robust and scalable components regardless of framework.

What is the best way to structure Tailwind v4 variants for buttons and cards?

Start with primitive utilities directly in markup for simple buttons and cards. Escalate to a CVA-based variant approach only when you need 3 or more variants, preventing unnecessary complexity in your UI component library.

Why does Tailwind v4 discourage premature abstraction in component design?

Tailwind v4 discourages premature abstraction because wrapping simple styles in components adds unnecessary complexity. Using CSS-first utilities directly in markup keeps your codebase simpler and more readable until complex variants are actually required.