frontend-theming
Use when the user asks to set up dark mode with CSS variables, light/dark themes, prefers-color-scheme, a theme toggle without flash, color-scheme…
от j4flmao★ 47 звёзд на GitHub
Установить frontend-theming в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Frontend Theming
Description: Implements theming — design tokens, theme definitions (light/dark), switching strategy, framework integration, and persistence. Triggered by "theming", "dark mode", "light mode", "theme switching", "CSS variables", "custom properties", "theme provider", "theme context", "color scheme", "prefers-color-scheme", "theme toggle", "design tokens".
Version: 2.0.0 Author: j4flmao License: MIT
Purpose
Deliver a robust, flicker-free theming system that supports light and dark modes — using CSS custom properties for design tokens, with OS preference detection, manual toggle, and SSR-safe persistence.
Agent Protocol
Trigger
User request includes any of: "theming", "dark mode", "light mode", "theme switching", "CSS variables", "custom properties", "theme provider", "theme context", "color scheme", "prefers-color-scheme", "theme toggle", "design tokens".
Input Context
- Framework (React, Vue, Svelte, vanilla, Tailwind)
- Existing styling approach (CSS modules, styled-components, Tailwind)
- SSR / SSG setup (Next.js, Nuxt, SvelteKit)
- Design token requirements (colors, spacing, typography)
Output Artifact
Theme system with CSS variables, switching logic, and persistence.
Response Format
## Token Architecture
<variable-naming, theme-structure>
## Implementation
<theme-provider, switching-logic, anti-flicker>
## Persistence
<localStorage, cookie, SSR-hydration>
—
Compression footer: frontend-theming/v1 | 3 sections | tokens: <count> | modes: <light|dark|system>
No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.
Completion Criteria
- All color/spacing/typography values use CSS custom properties
- Light and dark themes both defined
- System preference detected and applied as default
- Manual toggle overrides system preference
- Anti-flicker script prevents flash of wrong theme on load
- User preference persisted across sessions
Max Response Length
4096 tokens
Theming Architecture / Decision Trees
Theme Strategy Decision Tree
SSR application?
|-- YES (Next.js, Nuxt, SvelteKit) -->
| Anti-flicker is critical
| Strategy: inline script in <head> reads cookie/localStorage
| Set class on <html> before any paint
| Cookie enables server-side class injection
| Library: next-themes, nuxt-color-mode, or custom
|
|-- NO (CSR only, React SPA, Vue SPA) -->
| Anti-flicker still needed (can use loading attribute)
| Strategy: inline script in index.html <head>
| Set class on <html> before React/Vue mounts
|
|-- No JS (static HTML, minimal) -->
CSS-only: prefers-color-scheme media query
No toggle, no persistence
Token Architecture Decision Tree
How many themes?
|-- 2 (light + dark) -->
| Semantic tokens on :root (light) + [data-theme="dark"]
| Components reference semantic tokens only
| Simple, maintainable
|
|-- 3+ (light + dark + high-contrast + sepia) -->
| Use a class-based approach: [data-theme="high-contrast"]
| Consider token generation tool (Style Dictionary)
| Each theme overrides same set of semantic tokens
|
|-- Per-user / dynamic branding -->
Runtime token injection via CSS custom properties on a scoped element
CSS variables cascade allows component-level overrides
Token Naming Decision Tree
CSS custom property naming convention?
|-- Semantic (recommended) -->
| --color-surface-primary, --color-text-body
| Pros: meaning never changes, themes swap actual values
| Cons: need to know what "surface" means
|
|-- Appearance-based (avoid) -->
--color-white, --color-dark-gray
Pros: obvious values
Cons: when theme changes, --color-white may not be white
Workflow
1. Design Tokens Foundation
- Define CSS custom properties for all visual primitives.
- Semantic naming convention:
color-surface-primary,color-text-default,spacing-md,font-size-body,shadow-sm. - Categories: colors (surface, text, border, interactive), spacing (xs through 3xl), typography (font family, size, weight, line-height), shadows, radii, z-index.
- Tokens are consumed by components — never reference raw hex values.
- Token names describe purpose, not appearance.
2. Theme Definition
- Light theme: light background, dark text, subtle shadows.
- Dark theme: dark background, light text, softer shadows.
- Both themes override the same semantic tokens.
- Define themes in CSS (
:root+[data-theme="dark"]), JS object (for runtime switching), or both. - SSR: define theme as cookie for server-side class injection.
3. Theme Switching Strategy
- CSS class on
<html>for manual toggle (e.g.,data-theme="dark"). prefers-color-schememedia query for system default.- Combine both: system preference is initial, manual toggle sets c
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/design-tokens.md
- references/theme-implementation.md
- references/theme-performance.md
- references/theme-testing.md
- references/theming-architecture.md
- references/theming-tokens.md
FAQ
Что делает скилл frontend-theming?
Use when the user asks to set up dark mode with CSS variables, light/dark themes, prefers-color-scheme, a theme toggle without flash, color-scheme, light-dark() or multi-brand themes. Produces theme tokens as custom properties and a switching mechanism. Not for token tiers in a component library (use frontend-design-system).
Как установить скилл frontend-theming?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-theming запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…