Skip to main content
Docs: Theming

Theming

PIE's players, tools and elements read their colors from --pie-* custom properties. <pie-theme> computes those tokens and writes them onto one element, from which they inherit into every item, including inside shadow DOM.

The theme element

AttributeValuesDefault
themelight, dark or autolight
scopeself or documentself
providera provider id, auto or noneauto
schemea color-scheme iddefault (none)
variablesJSON of custom-property overridesnone

A mounted <pie-theme> writes its tokens inline, and an inline declaration beats any stylesheet rule, so a host stylesheet that sets --pie-* cannot override it. Change tokens through variables or a registered scheme. Without the element, the stylesheet-only path (tokens.css, color-schemes.css, font-sizes.css) follows the normal cascade.

Resolution order

Four layers, each overwriting the tokens the one before set: the base theme, the provider adapter's output, the resolved color scheme, and explicit variables.

pie-theme resolves four layers in order: the base theme light, dark or auto; provider adapter output such as DaisyUI; the resolved color scheme, ten built in plus registered ones; and explicit variables. The merged tokens are written onto the theme target.

Provider adapters

provider decides whether PIE content takes the host's look or PIE's own. none keeps the canonical palette, identical in every host. The built-in DaisyUI adapter maps DaisyUI's slots onto PIE tokens and raises text pairs to 4.5:1 contrast as it maps. registerPieThemeProvider adds an adapter for another design system.

Token registry

@pie-players/pie-theme/token-registry.json lists every public token with its owner, category and whether color schemes must set it. Registered names and values are part of the public surface. Token registry(opens in new tab)

Color schemes

A theme is presentation; a color scheme is an accommodation under WCAG 1.4.1, 1.4.3 and 1.4.11. A scheme replaces every color it covers, folds fixed hues such as chart categories into its two colors, and recolors authored inline colors in item content so dark ink never lands on a dark page. Ten ship built in:

black-on-whitewhite-on-blackrose-on-greenyellow-on-blueblack-on-roselight-gray-on-dark-graygrey-on-light-greypurple-on-light-greenblack-on-violetyellow-on-navy

A program with its own palettes registers them as partial overlays. Each entry is validated against the token registry, and an invalid one is rejected without dropping its siblings. Contrast problems come back as warnings on the returned receipt, because the palette is yours: read them.

Learners choose a scheme with the theme tool(opens in new tab), a section-level toolkit tool that sets scheme on the nearest <pie-theme> and keeps the choice per attempt through the toolkit's tool-state hooks.

Host chrome

<pie-theme> writes --pie-* tokens only, so switching a theme recolors PIE content and leaves your page's own UI alone. To carry an active accommodation into your chrome, alias your tokens to PIE's under [data-color-scheme], which is set only while a scheme is active.

pie-theme writes --pie-* tokens and data-color-scheme onto the theme target, and PIE content inherits them. Host chrome reads the host's own --color-* palette; while a scheme is set, an alias block in the host stylesheet points those tokens at --pie-*.

theme="dark" does not darken native controls such as select and scrollbars; that stays your page's own color-scheme declaration. A resolved color scheme sets it for you.

Font size

Set data-font-size on any ancestor of a player, or --pie-font-scale through variables. The presets match Learnosity's steps, which accommodation profiles are already written against.

PresetScale
normal1
large1.25
xlarge1.5
xxlarge1.75

Reference

How theming works(opens in new tab) · Theme README(opens in new tab) · Theming WCAG matrix(opens in new tab) · Accessibility