All skills
sergiodxa avatar

/frontend-tailwind-best-practices

@fa6e3fc

Tailwind CSS patterns and conventions for frontend apps. Use when writing component styles, layouts, or working with CSS classes.

Use this Skill: https://skilld.dev/gh/sergiodxa/agent-skills/frontend-tailwind-best-practices

This session only. Nothing lands on disk.

rulesaffordance-classes.md

≈469 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Affordance Classes

Create element-agnostic visual patterns (affordances) with Tailwind @utility, @apply, and @variant.

Why

  • Decouple appearance from element choice (button, label, a, summary)
  • Keep a single source of truth for interactive styles
  • Preserve Tailwind tree-shaking and IntelliSense
  • Let utilities override affordances without specificity fights

Pattern

Define affordances with @utility so they are tree-shakeable and show up in IntelliSense. Use :where() for zero specificity and @variant for readable states:

@utility ui-button {
  :where(&) {
    @apply inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-semibold;
    @apply bg-primary text-primary-foreground shadow-sm;

    @variant hover {
      @apply bg-primary/90;
    }

    @variant focus-visible {
      @apply outline-2 outline-offset-2 outline-primary;
    }
  }
}

@utility ui-input {
  :where(&) {
    @apply block w-full rounded-md border border-neutral-300 bg-white px-3 py-2;
    @apply text-neutral-900;

    @variant focus-visible {
      @apply border-primary outline-2 outline-offset-2 outline-primary;
    }
  }
}

Usage

// Label styled like a button
<label className="ui-button" htmlFor="document-upload">
  Choose file
</label>

// Utilities can still override
<button className="ui-button bg-red-600 hover:bg-red-500">Delete</button>

// Input affordance on any element that needs to look typeable
<input className="ui-input" />
<textarea className="ui-input" />

Rules

  1. Use a ui- (or similar) prefix to signal affordance classes
  2. Use @utility so affordances are tree-shakeable and discoverable
  3. Wrap styles in :where() to keep specificity at zero
  4. Use @variant blocks for readable state styles

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a collection of architectural guidelines and best practices for Tailwind CSS. It provides documentation on layout utilities, color schemes, and component styling patterns without any executable code or suspicious behaviors.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    11 files scanned · No issues

  • ZeroLeaks5mo

    1 finding · Score: 86/100

Signed by skilld at fa6e3fc. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago

README badge

README badge for sergiodxa/agent-skills/frontend-tailwind-best-practices