Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
existential-birds avatar

Tailwind V4

  • 764 installs
  • 74 repo stars
  • Updated July 21, 2026
  • existential-birds/beagle

tailwind-v4 is a frontend styling skill that implements reliable dark mode and theme switching with Tailwind CSS v4 for developers who need correct `dark:` variants and user-preference-aware themes.

About

tailwind-v4 is a skill from existential-birds/beagle focused on dark mode strategies in Tailwind CSS v4. The skill documents media-query detection via `prefers-color-scheme`, class-based and attribute-based theme toggles, and theme-switching implementation that respects user preferences. It shows v4 defaults where `@import 'tailwindcss'` enables `dark:` variants without extra configuration, plus generated CSS examples using oklch color values. Developers reach for tailwind-v4 when shipping theme toggles, fixing inconsistent dark styles, or migrating dark-mode behavior to Tailwind v4's variant model.

  • Media Query Strategy that automatically respects system prefers-color-scheme with zero JavaScript
  • Class-Based Strategy using the .dark class on the html element for manual theme toggling
  • Attribute-Based Strategy for granular control via data attributes
  • Theme Switching Implementation patterns with full user preference persistence
  • Respecting User Preferences guide covering both automatic and manual controls

Tailwind V4 by the numbers

  • 764 all-time installs (skills.sh)
  • +9 installs in the week ending Jul 24, 2026 (Skillselion tracking)
  • Ranked #457 of 2,245 Frontend Development skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/existential-birds/beagle --skill tailwind-v4

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs764
repo stars74
Security audit3 / 3 scanners passed
Last updatedJuly 21, 2026
Repositoryexistential-birds/beagle

How do you implement dark mode in Tailwind CSS v4?

Implement reliable dark mode and theme switching strategies using Tailwind CSS v4.

Who is it for?

Frontend developers building Tailwind CSS v4 UIs who need dependable dark mode across media, class, and attribute strategies.

Skip if: Projects on legacy Tailwind v3-only configs, backend API work, or teams not using Tailwind for styling.

When should I use this skill?

The user implements or debugs dark mode, theme toggles, or `dark:` variants in a Tailwind CSS v4 frontend.

What you get

Tailwind v4 CSS config, `dark:` variant usage, and theme-switching code respecting system preferences.

  • theme CSS configuration
  • dark mode component styles

Files

SKILL.mdMarkdownGitHub ↗

Tailwind CSS v4 Best Practices

Quick Reference

Vite Plugin Setup:

// vite.config.ts
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [tailwindcss()],
});

CSS Entry Point:

/* src/index.css */
@import 'tailwindcss';

@theme Inline Directive:

@theme inline {
  --color-primary: oklch(60% 0.24 262);
  --color-surface: oklch(98% 0.002 247);
}

Key Differences from v3

Featurev3v4
Configurationtailwind.config.js@theme in CSS
Build ToolPostCSS plugin@tailwindcss/vite
Colorsrgb() / hsl()oklch() (default)
Theme Extensionextend: {} in JSCSS variables
Dark ModedarkMode config optionCSS variants

@theme Directive Modes

default (standard mode)

Generates CSS variables that can be referenced elsewhere:

@theme {
  --color-brand: oklch(60% 0.24 262);
}

/* Generates: :root { --color-brand: oklch(...); } */
/* Usage: text-brand → color: var(--color-brand) */

Note: You can also use @theme default explicitly to mark theme values that can be overridden by non-default @theme declarations.

inline

Inlines values directly without CSS variables (better performance):

@theme inline {
  --color-brand: oklch(60% 0.24 262);
}

/* Usage: text-brand → color: oklch(60% 0.24 262) */

reference

Inlines values as fallbacks without emitting CSS variables:

@theme reference {
  --color-internal: oklch(50% 0.1 180);
}

/* No :root variable, but utilities use fallback */
/* Usage: bg-internal → background-color: var(--color-internal, oklch(50% 0.1 180)) */

OKLCH Color Format

OKLCH provides perceptually uniform colors with better consistency across hues:

oklch(L% C H)
  • L (Lightness): 0% (black) to 100% (white)
  • C (Chroma): 0 (gray) to ~0.4 (vibrant)
  • H (Hue): 0-360 degrees (red → yellow → green → blue → magenta)

Examples:

--color-sky-500: oklch(68.5% 0.169 237.323);  /* Bright blue */
--color-red-600: oklch(57.7% 0.245 27.325);   /* Vibrant red */
--color-zinc-900: oklch(21% 0.006 285.885);   /* Near-black gray */

CSS Variable Naming

Tailwind v4 uses double-dash CSS variable naming conventions:

@theme {
  /* Colors: --color-{name}-{shade} */
  --color-primary-500: oklch(60% 0.24 262);

  /* Spacing: --spacing multiplier */
  --spacing: 0.25rem;  /* Base unit for spacing scale */

  /* Fonts: --font-{family} */
  --font-display: 'Inter Variable', system-ui, sans-serif;

  /* Breakpoints: --breakpoint-{size} */
  --breakpoint-lg: 64rem;

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

No Config Files Needed

Tailwind v4 eliminates configuration files:

  • No `tailwind.config.js` - Use @theme in CSS instead
  • No `postcss.config.js` - Use @tailwindcss/vite plugin
  • TypeScript support - Add @types/node for path resolution
{
  "devDependencies": {
    "@tailwindcss/vite": "^4.0.0",
    "@types/node": "^22.0.0",
    "tailwindcss": "^4.0.0",
    "vite": "^6.0.0"
  }
}

Progressive Disclosure

  • Setup & Installation: See references/setup.md for Vite plugin configuration, package setup, TypeScript config
  • Theming & Design Tokens: See references/theming.md for @theme modes, color palettes, custom fonts, animations
  • Dark Mode Strategies: See references/dark-mode.md for media queries, class-based, attribute-based approaches

Gates (setup verification)

Before recommending @theme choices, OKLCH tokens, or v4 utilities, confirm the project is actually on the v4 integration path:

1. Build wiring: The Vite config loads tailwindcss() from @tailwindcss/vite, and the CSS entry uses @import 'tailwindcss'. If this fails, stop — fix wiring per references/setup.md first. 2. Major versions: package.json lists tailwindcss (and @tailwindcss/vite when using Vite) at major 4, not a v3 PostCSS-only toolchain. 3. Theme source: New theme tokens live in @theme / @theme inline in CSS — not tailwind.config.js extend (v3). If a v3 config still drives the theme, migrating wiring takes precedence over token tweaks.

Decision Guide

When to use @theme inline vs default

Use `@theme inline`:

  • Better performance (no CSS variable overhead)
  • Static color values that won't change
  • Animation keyframes with multiple values
  • Utilities that need direct value inlining

Use `@theme` (default):

  • Dynamic theming with JavaScript
  • CSS variable references in custom CSS
  • Values that change based on context
  • Better debugging (inspect CSS variables in DevTools)

When to use @theme reference

Use `@theme reference`:

  • Provide fallback values without CSS variable overhead
  • Values that should work even if variable isn't defined
  • Reducing :root bloat while maintaining utility support
  • Combining with inline for direct value substitution

Common Patterns

Two-Tier Variable System

Semantic variables that map to design tokens:

@theme {
  /* Design tokens (OKLCH colors) */
  --color-blue-600: oklch(54.6% 0.245 262.881);
  --color-slate-800: oklch(27.9% 0.041 260.031);

  /* Semantic mappings */
  --color-primary: var(--color-blue-600);
  --color-surface: var(--color-slate-800);
}

/* Usage: bg-primary, bg-surface */

Custom Font Configuration

@theme {
  --font-display: 'Inter Variable', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --font-display--font-variation-settings: 'wght' 400;
  --font-display--font-feature-settings: 'cv02', 'cv03', 'cv04';
}

/* Usage: font-display, font-mono */

Animation Keyframes

@theme inline {
  --animate-beacon: beacon 2s ease-in-out infinite;

  @keyframes beacon {
    0%, 100% {
      opacity: 1;
      transform: scale(1);
    }
    50% {
      opacity: 0.5;
      transform: scale(1.05);
    }
  }
}

/* Usage: animate-beacon */

Related skills

FAQ

Does Tailwind CSS v4 need extra config for dark mode?

tailwind-v4 notes that importing `tailwindcss` enables the `dark:` variant by default, using `prefers-color-scheme` media queries unless you switch to class or attribute strategies.

What dark mode strategies does tailwind-v4 cover?

tailwind-v4 documents media-query, class-based, and attribute-based dark mode plus theme-switching implementations that respect user system preferences in Tailwind CSS v4 projects.

Is Tailwind V4 safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.