Guides setting up charcoal-ui CSS variables by importing both theme and component stylesheets and adding the .ch-token-v2 class. Essential when charcoal components appear structurally correct but colorless.
Ships in charcoal. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The lowest-dependency way to use charcoal: load two stylesheets, add one class, then write var(--charcoal-*) anywhere.
npm install @charcoal-ui/react@^6 @charcoal-ui/theme@^6 react-aria react-stately
Pin the major. Design Token 2.0 and the CSS layout below are v6; v5 and earlier differ. Keep every @charcoal-ui/* package on the same major.
Peer dependencies of @charcoal-ui/react: react >=17.0.0, react-aria >=3.48.0, react-stately >=3.46.0. The two react-aria packages are not installed for you. React 18 and 19 both satisfy the range.
Skip @charcoal-ui/react if you only want tokens — @charcoal-ui/theme alone is enough.
// Load once at the app root.
import '@charcoal-ui/react/dist/index.css' // component implementation CSS
import '@charcoal-ui/theme/css/v2/light.css' // Design Token 2.0 — light
import '@charcoal-ui/theme/css/v2/dark.css' // Design Token 2.0 — dark
dist/index.css only consumes var(--charcoal-color-*). It never defines them.
The failure this causes is lopsided in a way that misleads people: colors go through var(), but layout does not. Padding, radius, font-size, and line-height are written as literal values, so they keep working. Load dist/index.css alone and you get a correctly shaped, correctly sized button with a transparent background and default black text. Nothing errors — an undefined custom property just makes that one declaration invalid, and the property falls back to its initial value.
If a charcoal component looks structurally right but colorless, this is why.
Prefer @charcoal-ui/react/dist/layered.css over dist/index.css when you need to override charcoal styles from your own CSS. Its contents are wrapped in @layer charcoal, so any unlayered rule of yours wins without a specificity fight. It requires iOS 15.4+.
Token 2.0 only applies inside .ch-token-v2.
<html class="ch-token-v2" lang="ja"></html>
The shipped selectors are:
/* light.css */
:root.ch-token-v2[data-theme='light'],
:root.ch-token-v2:not([data-theme]),
:root[data-theme='light'] .ch-token-v2,
:root:not([data-theme]) .ch-token-v2 {
--charcoal-color-…: …;
}
/* dark.css */
:root[data-theme='dark'] {
--charcoal-color-…: …;
}
Two consequences:
.ch-token-v2, no light-theme rule matches and every token is undefined.:root only, so data-theme="dark" applies page-wide regardless of .ch-token-v2.Put the class on <html>, or on an ancestor of the components you want themed. Variables inherit, so siblings are unaffected.
.card {
background-color: var(--charcoal-color-background-default);
color: var(--charcoal-color-text-default);
border: 1px solid var(--charcoal-color-border-secondary);
border-radius: var(--charcoal-radius-s);
padding: var(--charcoal-space-40);
}
Names follow --charcoal-<category>-<semantic>-<state>. Common ones: color-text-default / -secondary-default / -tertiary-default, color-background-default / -secondary / -tertiary, color-border-default / -secondary, color-container-primary-default, radius-xs|s|m|l, space-*. Read node_modules/@charcoal-ui/theme/dist/css/v2/light.css for the full list.
import { Button } from '@charcoal-ui/react'
export const Save = () => <Button variant="Primary">保存</Button>
Button imports its own CSS and uses no context. Wrap in CharcoalProvider only when you use overlays (Modal, DropdownSelector) — it supplies react-aria's SSRProvider and OverlayProvider.
document.documentElement.dataset.theme = 'dark' // or 'light'
For SSR, run this before paint to avoid a flash:
import { makeSetThemeScriptCode } from '@charcoal-ui/react'
;<script dangerouslySetInnerHTML={{ __html: makeSetThemeScriptCode() }} />
Use makeSetThemeScriptCode(), not <SetThemeScript />. The component's props type requires both localStorageKey and rootAttribute, so <SetThemeScript /> is a type error; makeSetThemeScriptCode() accepts zero arguments.
useThemeSetter() removes data-theme when the user is on "system", by design — it expects CSS to handle prefers-color-scheme. Design Token 2.0's CSS has no prefers-color-scheme block, so with the attribute removed :root:not([data-theme]) .ch-token-v2 matches and the page is stuck on light even on a dark OS.
Either always write an explicit data-theme, or add the missing bridge yourself:
@media (prefers-color-scheme: dark) {
:root:not([data-theme='light']).ch-token-v2,
:root:not([data-theme='light']) .ch-token-v2 {
/* copy the declarations from @charcoal-ui/theme/css/v2/dark.css */
}
}
Mirror light.css's selector shape. Targeting bare :root fails when .ch-token-v2 sits on a descendant: that descendant's own light values beat inherited dark values from an ancestor.
| Mistake | Fix |
|---|---|
Only dist/index.css loaded | Add @charcoal-ui/theme/css/v2/{light,dark}.css |
.ch-token-v2 missing | Add it to <html> or an ancestor |
<SetThemeScript /> with no props | Use makeSetThemeScriptCode() |
| Own CSS loses to charcoal's | Switch to dist/layered.css |
| Dark mode ignored on "system" | Add the prefers-color-scheme bridge above |
What SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/choosing-charcoal-stylingUse before writing or editing any code that imports @charcoal-ui, and whenever a project's charcoal setup is unverified or incomplete. Decides between the CSS variables, Tailwind and styled-components routes, and names the setup steps that are silently missing in most projects./choosing-charcoal-tokensUse before choosing any color, text style, spacing, radius or border value in code that uses @charcoal-ui, and whenever a literal is about to be written where a token exists — a hex color, a px padding or gap, a font-size, a border-radius or border-width. Charcoal has one correct token for each of these and the choice is prescribed, not a matter of taste. Also use when reviewing such code, or when deciding how dense, how loud or how bordered a screen should be./implement-figma-designUse when building a screen from a prepared Figma design pack — a design.md, a spec.json and an assets/ directory produced by prepare-figma-design — and when checking that what you built matches it. Needs no Figma access, no token and no Dev Mode seat. If there is no pack yet, prepare-figma-design makes one from a figma.com link./prepare-figma-designUse when you have a figma.com link or a local .fig export, and someone needs to build that design — including when you will build it yourself. One command turns it into the design's structure, its materials named as your own design tokens, the text of every node and the bitmaps it uses, as three files to commit. No Dev Mode seat: a read-only personal access token, or no credential at all from a .fig. Hand those files to implement-figma-design, which needs no Figma access./setting-up-charcoal-styledUse before writing or editing code that uses @charcoal-ui with styled-components, TokenInjector, createTheme or addThemeUtils, and whenever such a project's charcoal setup is unverified or incomplete./setting-up-charcoal-tailwindUse before writing or editing code that uses @charcoal-ui with Tailwind, and whenever such a project's charcoal setup is unverified or incomplete. The v2 token route still needs the theme CSS and the .ch-token-v2 opt-in, which the preset does not supply./charcoal:setting-up-charcoal-css-variablesfrom charcoal
npx claudepluginhub pixiv/charcoal --plugin charcoalOther plugins' skills for the same job