Problem/Motivation
Drupal Canvas writes the brand kit colours as CSS custom properties on :root. When the brand kit uses Bootstrap 5.3's own variable names (--bs-primary, --bs-body-bg, ...), the theme's compiled :root values override them, because Drupal always sorts module CSS before theme CSS. So editing a colour in Canvas > Brand kit changes nothing.
Steps to reproduce
- Install the site template (Educare) with Canvas.
- In Canvas > Brand kit, add a colour with the CSS variable
--bs-primary. - Change its value.
- The site keeps the theme's primary colour.
Proposed resolution
Leave Canvas's CSS order as it is and make the theme give way. A small PostCSS step in webpack.config.components.js moves only the light-mode colour custom properties of the :root, [data-bs-theme=light] rule into a zero-specificity :where(:root, [data-bs-theme="light"]) rule. The brand kit's :root { --bs-primary: ... }, which loads before the theme, then wins whatever the order, and the theme's values stay as the fallback.
Fonts, radii, shadows, the focus ring and the other non-colour variables keep normal specificity. Dark mode rules are untouched, and Bootstrap's own _root.scss is used unchanged. components/base/root/root.css is rebuilt: every declaration is identical, only the grouping changed. The earlier load-order hook is reverted, so no PHP change remains.
Related: Educare recipe issue #3638670 and its merge request !109.
Remaining tasks
- ✅ File an issue
- ✅ Addition/Change/Update/Fix: zero-specificity colour defaults through a PostCSS build step
- ❌ Testing to ensure no regression: default look and brand kit Primary and Body background checked on the dev site, CSS aggregation on and off and in the Canvas editor preview; pipeline still to pass
- ➖ Automated unit/functional testing coverage
- ➖ Developer Documentation support
- ➖ User Guide Documentation support
- ➖ UX/UI designer responsibilities
- ➖ Accessibility and Readability
- ❌ Reviewed by a human
- ❌ Code review by maintainers
- ❌ Full testing and approval
- ❌ Credit contributors
- ❌ Review with the product owner
- ❌ Update Release Notes
- ❌ Release, before the Educare recipe change
User interface changes
- N/A
API changes
- N/A
Data model changes
- N/A
Release notes snippet
- The theme lets Drupal Canvas brand kit colours that use Bootstrap's variable names override its own colours, without changing Canvas's CSS order.
AI-Generated: Yes
Issue fork vartheme_bs5_educare-3639239
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
rajab natshah