Root cause, confirmed on the live 2026.8.3 instance: card-mod injects card-mod-root-yaml into a shadow root, and an import rule inside a shadow tree is never fetched. DevTools showed --ha-font-family-body resolving correctly to the Geist stack on documentElement while no request to fonts.googleapis.com was made at all, so every surface fell back to the system font. Appending the same stylesheet to document.head from the console fixed it immediately. The font now loads from www/geist.js through frontend.extra_module_url, which runs against the real document. README promotes this from an optional offline note to required setup. Also fixed, both found while investigating: - ha-card-header-font-family was never set, so card headers kept HA Roboto while body text used the theme font. This is what the inspected element was showing. - CSS partials checked out with CRLF leaked literal escaped carriage returns into the inlined card-mod block; indent() now strips them. test/font.test.mjs locks in the root cause: no partial may carry an import rule, the loader module must target document.head and be idempotent, card headers must match body font, and the artifact must contain no stray CRs. The cardmod test that asserted the import belonged in root.css is inverted — it encoded the broken approach. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
shadcn theme for Home Assistant
A shadcn/ui theme for Home Assistant — light and dark,
built from shadcn preset b7CSc0v9E (style mira, base mist, accent blue,
radius small, font geist).
Cards are bordered rather than shadowed, radii are tight (0.45rem), and the
palette is the preset's own OKLCH tokens converted to the hex and RGB forms
Home Assistant needs. 218 theme variables per mode.
Built and verified against Home Assistant 2026.8.3.
Prerequisites
- Home Assistant 2026.8.0 or later.
- card-mod — install via HACS (Frontend → card-mod).
card-mod is optional but recommended. The theme is built in two layers:
| Layer | What it does | Without card-mod |
|---|---|---|
| 1 — theme variables | All colour, radius, borders, fonts, entity-state colours | Works fully |
| 2 — card-mod CSS | Card-header weight, card hover border, flat dialogs | Silently skipped |
Layer 1 carries the entire visual identity. Without card-mod you lose polish, not the theme.
Install (HACS)
-
HACS → Themes → ⋮ → Custom repositories → add this repository, category Theme.
-
Install shadcn theme.
-
Make sure your
configuration.yamlloads themes:frontend: themes: !include_dir_merge_named themes -
Restart Home Assistant.
-
Profile (click your name, bottom-left) → Theme → shadcn.
Install (manual)
- Copy
themes/shadcn/shadcn.yamltoconfig/themes/shadcn/shadcn.yaml. - Add the
frontend:block above toconfiguration.yamlif it isn't there. - Restart Home Assistant, then pick shadcn in your profile.
Set Auto in the theme picker to follow your device's light/dark preference.
Font (required setup)
Geist needs one extra step. A theme YAML cannot ship a font, and the obvious route — importing the stylesheet from the card-mod layer — does not work: card-mod injects its CSS into a shadow root, and an import rule inside a shadow tree is never fetched. Confirmed on HA 2026.8.3: the font variables applied correctly while the browser never requested the font at all, so every surface silently fell back to the system font.
The stylesheet has to reach the real document head, which is what
extra_module_url is for:
-
Copy
www/geist.jsfrom this repo to<config>/www/geist.js. -
Add to
configuration.yaml:frontend: extra_module_url: - /local/geist.js -
Restart Home Assistant, then hard-reload the browser (Ctrl/Cmd+Shift+R).
Skip this and the theme still works — colours, borders, radii and spacing are
all unaffected. You just get your system font instead of Geist, because the
font stack falls back to -apple-system, "Segoe UI", Roboto, sans-serif.
Offline instances: put Geist's .woff2 in <config>/www/ and swap the
<link> in geist.js for an inline @font-face pointing at /local/ — the
file carries a commented example.
Verification checklist
Worth walking once after install. Each row names a shadcn component, where its Home Assistant counterpart lives, and what should have changed.
| Look at | shadcn component | Expect |
|---|---|---|
| Any dashboard card | card |
1px border, tight corners, no drop shadow |
| Sidebar | sidebar |
Muted surface, accent on the selected item |
| A light or switch entity | switch |
Accent blue when on, not HA's default blue |
| Click an entity → dialog | dialog (more-info) |
Bordered surface, flat — no elevation shadow |
| Settings → Devices | table |
Themed data table |
Press e (or c) |
command (Quick Bar) |
Themed palette |
| An entity's history graph | chart |
Calm monochrome series, all clearly visible |
| An entity that is unavailable | alert |
Distinct from merely off — not the same grey |
| Assist (voice icon, top right) | bubble / message |
Themed conversation |
| Settings → Devices → Add | form / field |
Themed inputs and dropdowns |
Please check these specifically
These could not be verified without a running instance, and a card-mod selector that no longer matches fails silently — it produces no error, it just does nothing. If a surface looks unchanged, that is the signal.
- more-info dialog on a phone. At narrow widths Home Assistant renders a
bottom sheet, which uses a separate
--ha-bottom-sheet-*variable family this theme does not set. It may appear unthemed. Known gap. - Keyboard focus. This theme ships no focus ring of its own (see Not delivered below), so Home Assistant's default focus styling should be intact and visible. Confirm tabbing still shows focus clearly.
- Card header weight and the card hover border. These rely on card-mod reaching into a card's shadow root. Confirm they actually changed.
- Geist actually loading. Only after the Font (required setup) step
above. If text still looks like Roboto, check
/local/geist.jsloads (DevTools → Network) and hard-reload.
Please report anything that looks unchanged rather than wrong — silence is how this layer fails.
Not delivered
Three things were written, found to be silent no-ops, and removed rather than
shipped. Each is documented in the relevant src/card-mod/*.css file:
- A global focus ring.
outlinedoes not inherit across shadow boundaries, so the rule could not reach most controls, and a shadow host matching:focus-visiblewould have outlined the whole app viewport. ha-selectdropdown radius and combo-box row radius. Both targets sit inside their parent's shadow root, which a descendant selector cannot cross.
Delivering the latter two needs card-mod's $ shadow-descent syntax, which
could not be verified from this repository. If you want to try it on your own
instance, add to a dashboard's raw config (untested):
card_mod:
style:
ha-select $: |
ha-dropdown::part(menu) {
border-radius: var(--ha-border-radius-md);
border: 1px solid var(--divider-color);
}
Coverage
All 63 components in the @shadcn registry:ui namespace are accounted for in
COMPONENTS.md: 59 map to a real Home Assistant surface,
3 have no counterpart (context-menu, resizable, questionnaire), and
1 (carousel) is partial. Gaps are documented as gaps, not padded out.
Development
npm install # one devDependency (js-yaml)
npm test # 138 tests
npm run build # regenerate themes/shadcn/shadcn.yaml
themes/shadcn/shadcn.yaml is a committed build artifact. Change a token or
the mapping, run npm run build, and commit the regenerated YAML in the same
commit.
The test suite is not decorative — it enforces the two decisions that make this theme correct:
- The accent is split by role. Home Assistant uses
--primary-coloras a foreground colour; shadcn uses--primaryonly as a filled surface. Mapped one-to-one, this preset's dark primary sits at 1.97:1 on a dark card — every "on" icon a near-invisible smudge. Fill and foreground roles are therefore mapped separately, and a test fails if the fill colour ever lands in a foreground slot. - Every foreground/background pair is contrast-gated. Text pairs at 4.5:1, graphical objects at 3:1, including all five chart series and all eight energy colours — not just the ones that pass.
Card-mod selectors are never written from memory. Each is verified against
home-assistant/frontend at build 20260729.7 — the build HA 2026.8.3 ships —
and cited in src/card-mod/SELECTORS.md.