tailwind-4

Guide Tailwind CSS styling with cn() utility and semantic classes.

2|Updated Jun 11, 2024
One-click install
npx skills add https://github.com/gutierrezp22/administracion-departamentos --skill tailwind-4-gutierrezp22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tailwind-4
Source: https://github.com/gutierrezp22/administracion-departamentos/tree/main/.cursor/skills/tailwind-4
Command: npx skills add https://github.com/gutierrezp22/administracion-departamentos --skill tailwind-4-gutierrezp22

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides guidance on best practices for styling with Tailwind CSS, ensuring efficient, maintainable, and scalable code.

Core Features & Use Cases

  • Styling Decision Tree: Helps decide between className, style prop, or cn() utility.
  • Critical Rules: Enforces rules like avoiding var() in className and using semantic Tailwind colors.
  • cn() Utility: Demonstrates effective use of the cn() utility for conditional and merged classes.
  • Use Case: When you're unsure how to apply a specific style in Tailwind, consult this Skill's decision tree and examples for the optimal approach.

Quick Start

Use the tailwind-4 skill to understand when to use the cn() utility for conditional classes.

Frequently Asked Questions about tailwind-4

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

FAQPage Schema
How do I use the cn() utility for conditional Tailwind CSS classes?

Use the `cn()` utility for conditional Tailwind CSS classes to safely merge and override styles without conflicts. It evaluates conditions and merges class names, ensuring later classes take precedence over earlier ones.

Why should I avoid var() in my Tailwind CSS class names?

Avoid using `var()` directly in Tailwind CSS class names because it breaks utility class parsing. Instead, use semantic Tailwind theme variables and predefined utility classes to maintain scalable and maintainable styling.

What is the best way to apply dynamic values in Tailwind CSS without breaking styling?

The best way to apply dynamic values in Tailwind CSS is using the `cn()` utility or inline styles for truly dynamic data. Avoid constructing class names dynamically with string interpolation, as Tailwind cannot detect them at build time.

Can I use direct hex colors in Tailwind CSS utility classes for custom styling?

Direct hex colors should not be used in Tailwind CSS utility classes. Use semantic Tailwind colors and theme variables instead to ensure consistency across your project and maintain the ability to update themes globally.

How do I style library components with Tailwind CSS without losing default styles?

Style library components with Tailwind CSS by using the `cn()` utility to merge your custom classes with the component's default classes. This ensures your custom styles override defaults cleanly without stripping necessary base styles.

When should I choose the style prop over utility classes in Tailwind CSS?

Choose the `style` prop over Tailwind CSS utility classes when dealing with highly dynamic values that depend on runtime variables. For static or conditional styling, use the `cn()` utility with semantic classes.