All skills
asyrafhussin avatar

/tailwind-best-practices

@481a693

Tailwind CSS patterns and conventions. Use when writing responsive designs, implementing dark mode, creating reusable component styles, configuring Tailwind, or migrating from v3 to v4. Triggers on tasks involving Tailwind classes, responsive design, dark mode, CSS styling, or "migrate to Tailwind v4".

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

This session only. Nothing lands on disk.

rulesv4-theme-configuration.md

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

Why It Matters

In Tailwind v4, tailwind.config.js is gone. All theme customisation happens in CSS using the @theme directive. Values defined in @theme become both CSS custom properties and Tailwind utility classes automatically — no JavaScript configuration required.

Incorrect

// ❌ tailwind.config.js does not exist in v4
module.exports = {
  theme: {
    extend: {
      colors: { brand: '#3b82f6' },
      fontFamily: { display: ['Satoshi', 'sans-serif'] },
    },
  },
}

Correct

Extend the default theme

/* app.css */
@import "tailwindcss";

@theme {
  /* Colors — generates bg-brand-*, text-brand-*, border-brand-* etc. */
  --color-brand-500: #3b82f6;
  --color-brand-600: #2563eb;

  /* Fonts — generates font-display, font-mono etc. */
  --font-display: "Satoshi", sans-serif;
  --font-sans: "Inter", sans-serif;

  /* Breakpoints — generates 3xl:* variant */
  --breakpoint-3xl: 1920px;

  /* Spacing — generates p-18, m-18, w-18 etc. */
  --spacing-18: 4.5rem;

  /* Shadows — generates shadow-soft */
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.08);

  /* Custom animations */
  --animate-fade-in: fade-in 0.3s ease-out;

  @keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

Override an entire namespace (remove defaults)

@import "tailwindcss";

@theme {
  /* Reset all default colors, then define only yours */
  --color-*: initial;
  --color-white: #fff;
  --color-black: #000;
  --color-primary: #3f3cbb;
  --color-secondary: #121063;
}

Use theme values in arbitrary utilities

<!-- Generated utility class -->
<div class="bg-brand-500 font-display shadow-soft">

<!-- Or reference the CSS variable directly -->
<div class="bg-[var(--color-brand-500)]">

Reference theme variables in custom CSS

.my-component {
  color: var(--color-brand-500);
  font-family: var(--font-display);
  padding: var(--spacing-18);
}

Recommended Patterns

v3 config v4 @theme equivalent
colors.brand --color-brand-*
fontFamily.display --font-display
screens['3xl'] --breakpoint-3xl
spacing['18'] --spacing-18
boxShadow.soft --shadow-soft
keyframes + animation --animate-* + @keyframes inside @theme

Reference: https://tailwindcss.com/docs/theme

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a comprehensive collection of best practices, rules, and code patterns for Tailwind CSS v3 and v4. It provides guidance on responsive design, dark mode, component architecture, and theme configuration. No security issues were detected in the instructions or provided code snippets.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    32 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

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

Last checked against GitHub last month.

Steadyupdated 7 months ago
Other metadata
metadata
{
  "author": "agent-skills",
  "version": "1.0.0",
  "tailwindVersion": "3.4+ / 4.0+"
}

README badge

README badge for asyrafhussin/agent-skills/tailwind-best-practices