agentleFS
Yahiasherif002Yahiasherif002/claude-skills/theme-toggle/SKILL.md

theme-toggle

Skill1 starsChanged 5 months agoMITView on GitHub

Add a proper, persisted light/dark theme to a React + Tailwind/CSS-variables site — a ThemeProvider that toggles a `.dark` class on <html>, remembers the choice in localStorage, and a complete CSS token palette for both modes. Includes the trick for keeping intentionally-dark panels (terminals, code blocks) dark in BOTH themes. Use when the user wants a dark/light mode switch, theming that actually works (not half-broken), or to convert a dark-only site to switchable.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add a toggle button anywhere:

    line 24
  2. Very specific:

    Make sure components use token classes (bg-background, text-foreground, text-muted-foreground, border-border, etc.) rather than hardcoded …

    line 29

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Theme Toggle (light / dark)

Switchable light/dark done right: CSS-variable token palettes for both modes, a .dark class on <html>, persistence, and a useTheme() hook + toggle. Components that use the tokens (bg-background, text-foreground, border-border, …) adapt automatically.

What it produces

  • ThemeProvider.tsx — context provider that toggles .dark on documentElement, persists to localStorage, exposes useTheme() → { theme, toggleTheme }. Defaults to dark (configurable), switchable flag.
  • tokens.css — :root = light palette, .dark = dark palette, for the standard shadcn-style token set (background/foreground/card/primary/secondary/muted/accent/border + syntax colors).

How to use it

  1. Copy references/ThemeProvider.tsx and import its CSS tokens (references/tokens.css).
  2. Wrap the app: <ThemeProvider defaultTheme="dark" switchable>…</ThemeProvider>.
  3. Add a toggle button anywhere:
    const { theme, toggleTheme } = useTheme();
    <button onClick={toggleTheme}>{theme === "dark" ? "☀︎" : "☾"}</button>
  4. Make sure components use token classes (bg-background, text-foreground, text-muted-foreground, border-border, etc.) rather than hardcoded colors — those are what flip between modes.

The "keep terminals dark" trick

Terminals / code panels should stay dark even in light mode (a terminal is dark). Since the tokens are defined on the .dark selector, just add className="dark" to that panel's wrapper — its descendants inherit the dark token values regardless of the page theme:

<div className="dark bg-black text-foreground">…terminal stays dark & readable in both modes…</div>

Gotchas

  • Define tokens on :root (light) and .dark — not the reverse. Apply .dark to <html> so it cascades everywhere (incl. portals/dialogs).
  • Hardcoded hex colors (#1e1e1e, text-[#d4d4d4]) won't theme — convert them to tokens, or leave a page intentionally dark by scoping it with .dark.
  • Raise --muted-foreground lightness for light mode (low-contrast gray is the usual readability complaint).
  • Tailwind v4: tokens map via @theme; v3: via tailwind.config theme.extend.colors.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.