# Theming: Web Components _Path: en/frontend/micro-frontends/web-component-theming_ ## Table of Contents - Theming: Web Components ## Content # Theming: Web Components [Theming reference](./theming.md) covers the full CSS variable catalog. This doc covers how a web component receives the theme through shadow DOM. --- ## How the theme reaches your component Shadow DOM blocks CSS cascade — stylesheets written outside your component do not apply inside it. However, CSS custom properties (variables) **do** cross the shadow boundary. This means: - `--p-primary-500` and all other `--p-*` vars from the host are available inside your shadow root automatically — no configuration needed. - PrimeVue component styles, Tailwind utilities, and other rule-based stylesheets do **not** cascade in — you must load them explicitly via `hostCssKeys`. --- ## Customization levels **L1 — Global:** CSS custom properties (`--p-*` vars) cross the shadow boundary automatically. No action needed to receive L1 vars inside your WC. **L2 — Scoped:** Same as L1 for custom properties. Stylesheet-based CSS (PrimeVue, Tailwind) does not cascade — use `hostCssKeys` to load these explicitly into the shadow root. **L3 — Per-page config_overrides:** CSS vars set via operator `config_overrides` also reach your shadow root as custom properties, because they are set on `:root` of the host page. **What WCs cannot receive from the facade:** `customCSS` rules (e.g. `.p-button { border-radius: 12px }`) do not cross the shadow DOM boundary. If a facade-level class rule must affect PrimeVue components rendered inside a WC's shadow root, the rule must be replayed inside the WC's own styles, or lifted to a `--p-*` token form (which does cross the boundary). --- ## Receiving theme CSS **Do NOT externalize `@wippy-fe/theme`** in your Vite config. Shadow DOM cannot inherit an external stylesheet from the host page. Bundle the theme or load its CSS via `hostCssKeys`. Externalize only `vue`, `pinia`, `@iconify/vue`, and `@wippy-fe/proxy`. ### `hostCssKeys` — runtime CSS loading Declare which host-served CSS assets the WC runtime should inject into your shadow root. Add to `wippyConfig.hostCssKeys`: ```typescript static get wippyConfig(): WippyElementConfig { return { propsSchema: pkg.wippy.props as WippyPropsSchema, hostCssKeys: ['themeConfigUrl', 'iframeCssUrl'] as const, inlineCss: stylesText, } } ``` | Key | What it loads | Size | When to include | |---|---|---|---| | `themeConfigUrl` | `theme-config.css` — the full `--p-*` CSS variable system | ~8 KB | **Always.** Without it, `:host` styles can't reference `--p-*` vars. | | `primeVueCssUrl` | All PrimeVue component CSS (unstyled mode) | ~455 KB | Only if the WC renders PrimeVue components (`