Globally customize HeroUI v3 and author complete custom themes with CSS only. Use when restyling HeroUI components app-wide, changing design tokens (colors, radius, shadows, fields), overriding BEM component classes, adding variants, creating a named light/dark theme, or using @heroui/styles on plain HTML and non-React frameworks. Keywords: HeroUI theme, theming, custom theme, design tokens, CSS variables, oklch, BEM, data-theme, dark mode, @heroui/styles, global styles.
100%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Medium
Suggest reviewing before use
HeroUI's look lives entirely in @heroui/styles: plain CSS made of theme tokens and BEM component classes in cascade layers. @heroui/react only adds behavior and puts those class names on the DOM. So everything visual can be changed globally with CSS — no component wrappers, no forks, no JavaScript — and the same CSS works on any framework or plain HTML.
Use this skill to customize HeroUI globally or to build a full theme. For building UIs with the components, use the heroui-react skill.
curl -fsSL https://heroui.com/install | bash -s heroui-theming@layer theme, base, components, utilities; ← declared by @heroui/styles
theme tokens --accent, --radius, --surface-shadow, --field-border…
base resets border color, overlay keyframes
components BEM classes .button, .button--primary, .card__header, .switch__thumb…
utilities Tailwind bg-accent, rounded-xl, shadow-surface, status-focused…--accent → Tailwind mapping --color-accent: var(--accent) → utility bg-accent → component .button--primary { --button-bg: var(--accent) }. Change the token and the whole chain follows.-foreground is the text placed on them. They change as a pair.:root, .light, [data-theme="light"]; dark on .dark, [data-theme="dark"].Never invent a token, class, or selector. Read them from the project's own node_modules (no network needed):
node scripts/list_tokens.mjs # tokens: shared, light, dark, Tailwind mapping
node scripts/list_component_classes.mjs # every component stylesheet
node scripts/list_component_classes.mjs button switch # blocks, elements, modifiers, states, custom properties, tokens read
node scripts/list_component_classes.mjs modal --css # plus the raw CSSscripts/ is this skill's folder. Run the scripts with the project root as the working directory — they resolve @heroui/styles from there — or pass --dir <path-to>/node_modules/@heroui/styles. The files they read:
| What | Path in the installed package |
|---|---|
| Token values | node_modules/@heroui/styles/dist/themes/default/variables.css |
| Tailwind mapping | node_modules/@heroui/styles/dist/themes/shared/theme.css |
| Component CSS | node_modules/@heroui/styles/dist/components/<name>.css |
Read only. Never edit node_modules.
Use the lowest rung that solves the request. Each rung up costs more to maintain.
| # | The request sounds like | Use | Reference |
|---|---|---|---|
| 1 | "Change the brand color / make everything rounder / flatter" | Theme tokens | tokens.md |
| 2 | "Primary buttons should be black" (one component's colors) | That component's custom properties | components.md |
| 3 | "All buttons uppercase / cards get a border" (shape, type, layout, states) | BEM override in @layer components | components.md |
| 4 | "Add a gradient button next to the existing ones" | New modifier class | components.md |
| 5 | "Create a theme called X" / a full visual identity with light + dark | Named theme folder | theme-recipe.md |
| 6 | "Use preset X but in our colors" (a theme someone else wrote) | Brand palette layered over it | theme-recipe.md |
A one-off tweak on a single element is not theming: use className utilities there.
All snippets below go in the app's main CSS file, after the HeroUI import:
@import "tailwindcss";
@import "@heroui/styles";
/* customizations here */@layer theme {
/* Same in both modes */
:root {
--accent: oklch(0.55 0.2 300);
--accent-foreground: var(--snow);
--radius: 0.375rem;
}
/* Mode-specific tokens need BOTH blocks, light first */
:root,
.light,
[data-theme="light"] {
--background: oklch(0.98 0.01 300);
}
.dark,
[data-theme="dark"] {
--background: oklch(0.16 0.02 300);
}
}A token set only on :root also applies in dark mode, because your rule outranks the default dark block. That is right for --accent or --radius, and wrong for --background, --surface, --foreground, shadows: give those a dark value too.
Hover, soft, and border-level colors (--accent-hover, --accent-soft, --field-hover…) are calculated from the base tokens. Do not set them unless the result needs tuning.
Many components paint from their own properties (--button-bg, --chip-bg, --switch-control-bg-checked…). They are declared on the component class, so set them there, not on :root:
@layer components {
.button--primary {
--button-bg: var(--foreground);
--button-bg-hover: color-mix(in oklab, var(--foreground) 88%, var(--background));
--button-bg-pressed: color-mix(in oklab, var(--foreground) 80%, var(--background));
--button-fg: var(--background);
}
}Hover, pressed, focus, and disabled keep working because the base rules still do the painting.
@layer components {
.button {
@apply font-semibold tracking-wide uppercase;
}
.card {
@apply border border-border;
}
/* `.card` now sets a border: re-assert the modifier it would clobber */
.card--transparent {
@apply border-none;
}
/* States: the pseudo-class AND the data attribute, as in the base file */
.button:active,
.button[data-pressed="true"] {
transform: scale(0.95);
}
}Add a class in @layer components that assigns the component's custom properties (all of them), e.g. .button--brand { --button-bg: var(--success); --button-bg-hover: var(--success-hover); --button-bg-pressed: var(--success-hover); --button-fg: var(--success-foreground); }. Use it with <Button className="button--brand"> or <button class="button button--brand">.
A theme is a folder with one fixed structure, imported after HeroUI and activated on <html>:
src/themes/<name>/
├── index.css
├── variables.css
└── components/
├── index.css
└── <component>.css # one file per overridden component/* ── themes/<name>/index.css ── */
@import "./variables.css" layer(theme);
@import "./components/index.css" layer(components);
/* ── themes/<name>/variables.css: the full palette in BOTH blocks ── */
.<name>-light,
[data-theme="<name>-light"] {
color-scheme: light;
/* --background, --foreground, --surface*, --overlay, --default, --accent, status colors,
--field-*, --border, --separator, --focus, --radius, shadows, your own --<name>-* tokens */
}
.<name>-dark,
[data-theme="<name>-dark"] {
color-scheme: dark;
/* the same tokens, dark values */
}
/* ── themes/<name>/components/index.css ── */
@import "./button.css";
@import "./card.css";
/* ── app/globals.css ── */
@import "tailwindcss";
@import "@heroui/styles";
@import "../themes/<name>/index.css";<html data-theme="<name>-light">
<body class="bg-background text-foreground"></body>
</html>Switch to dark with data-theme="<name>-dark" (a class of the same name also works). Read theme-recipe.md before writing a theme: it has the step-by-step process and a complete worked example with light + dark variables and five component files.
A theme with a tactile look (raised, pressed, outlined) applies that material to every "on" state, not only buttons: switch, checkbox, radio, toggle button, tab indicator, slider, progress and meter fills, selected calendar days. The recipe's Material section lists each selector and the pseudo-elements already in use.
Keep the preset's material and swap its palette: import the preset, then your brand.css with layer(theme), keyed on the preset's selectors. Point every token the preset tints at your palette (--overlay: var(--surface), --field-border: var(--border)) instead of copying its component CSS. Steps: Restyling a theme you didn't write.
@heroui/styles works on plain HTML and any framework: load the CSS, put the BEM classes on real elements, set state attributes yourself.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@heroui/styles@3/dist/heroui.min.css" />
<button class="button button--primary">Save</button>
<button class="switch" role="switch" aria-checked="true">
<span class="switch__content">
<span class="switch__control"><span class="switch__thumb"></span></span>
Notifications
</span>
</button>With a Tailwind v4 build, use @import "tailwindcss"; @import "@heroui/styles"; instead. The prebuilt file has no Tailwind utilities and no @apply. Details, a runnable page, selective imports, and variant functions for Vue/Svelte: any-framework.md.
oklch() for colors. Keep hue steady across a ramp and move lightness.-foreground pairs readable (WCAG AA, 4.5:1 for text). Check soft variants (--accent-soft + --accent-soft-foreground) too.:hover + [data-hovered="true"], :active + [data-pressed="true"], :focus-visible + [data-focus-visible="true"], :disabled + [data-disabled="true"]/[aria-disabled="true"]). Copy the selector list from the base file; where it deliberately uses only one form, do the same.@layer components, never unlayered (unlayered CSS would also beat className utilities) and never with !important.box-shadow: on focusable components use shadow utilities (@apply shadow-[…]) rather than raw box-shadow, and never set a shadow token to none (use 0 0 0 0 transparent).transition, add @apply motion-reduce:transition-none;.<html>. Overlays portal to <body>, and calculated tokens only recompute on the root element.@apply, className, and variant maps, write full names (button--brand); never build them from strings.node_modules or copy HeroUI's CSS wholesale; override the smallest part.:root { --accent: … } silently beats a named theme.--radius and --spacing in px so only text scales.Build the CSS first (an unknown utility in @apply fails the build). Then, in light and dark:
bg-background text-foreground on <body>)DESIGN.md, update it to the new tokensLoad on demand: tokens.md (every token, default, utility, effect), components.md (BEM conventions, states, per-component properties), theme-recipe.md (full theme process + worked example), any-framework.md (plain HTML, Vue, Svelte, CDN, selective imports).
heroui-inc/heroui
796b692
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.