Render Pipeline
When to Use
Use this when debugging what UI Skins does at render time, or when hooking into the injection process.
Pattern
HookHandler\PreprocessHtml runs at hook_preprocess_html():
- Read theme settings —
theme_get_setting('ui_skins_css_variables')andtheme_get_setting('ui_skins_theme') - Resolve theme dependencies — recursively collect all transitively activated theme plugins
- Build attribute payload — merge each active theme's
key/valueinto$variables['html_attributes'](fortarget: html) or$variables['attributes'](fortarget: body) viaAttributeHelper::mergeCollections() - Build CSS variable payload — for each declared CSS variable, emit
selector { --plugin-id: value; }rules per scope, concatenate, output as a<style>tag in the page head - Attach libraries — for each active theme plugin with a
library, append to$variables['#attached']['library']
Storage in Theme Settings
# config/sync/{theme}.settings.yml (excerpt)
ui_skins_css_variables:
brand_primary:
":root": "#aa00ccff"
ui_skins_theme: dark
Decision: where to hook in
| Goal | Hook / Service |
|---|---|
Modify the rendered <style> tag |
hook_preprocess_html() after UI Skins (use higher-weight module) |
| Conditionally activate a theme | Override theme settings via hook_form_system_theme_settings_alter() |
Common Mistakes
- Expecting the active theme selection to flow into Layout Builder context → It doesn't. UI Skins is global per-page
- Cache invalidation surprises →
theme_settingsconfig changes invalidate render caches automatically. Custom alters need explicit cache tag bubbling
See Also
- Code Reference Map
- Theme Authoring
- Reference:
src/HookHandler/PreprocessHtml.php,src/Form/CssVariablesThemeSettingsForm.php