Skip to content

Add --bs-*-rgb variable overrides for Bootstrap 5.3 utility classes#813

Merged
jjroelofs merged 3 commits into
8.xfrom
jur/8.x/812-add-bs-rgb-variable-overrides
May 18, 2026
Merged

Add --bs-*-rgb variable overrides for Bootstrap 5.3 utility classes#813
jjroelofs merged 3 commits into
8.xfrom
jur/8.x/812-add-bs-rgb-variable-overrides

Conversation

@jjroelofs

Copy link
Copy Markdown
Collaborator

Linked issues

Solution

Bootstrap 5.3 utility classes (.text-primary, .bg-primary, .border-primary, .link-primary, .focus-ring-primary, etc.) consume the -rgb triplet form of CSS custom properties via rgba(), not the hex form. For example:

.text-primary {
  color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important;
}

We were overriding --bs-primary (hex) but not --bs-primary-rgb (triplet), so these utility classes ignored the theme palette entirely. This adds generation of all 11 --bs-*-rgb variables from palette hex values using the existing Color::hexToRgb() utility already imported in the file.

Scope of affected files: features/sooper-colors/colors-theme-settings-css.inc only.

Checklist

  • I have read the CONTRIBUTING.md document.
  • My commit messages follow the contributing standards and style of this project.
  • My code follows the coding standards and style of this project.
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Need to run update.php after code changes
  • Requires a change to end-user documentation.
  • Requires a change to developer documentation.
  • Requires a change to QA tests.
  • Requires a new QA test.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jjroelofs

Copy link
Copy Markdown
Collaborator Author

Review finding:

[P1] Preset color schemes still ship Bootstrap's default -rgb values

These overrides are only emitted inside :root.dxpr-scheme-custom, so they fix sites using the custom palette but not any of the built-in schemes. The theme always loads css/base/variables.css, and the preset scheme definitions generated from scss/base/variables.scss still stop at --bs-tertiary-bg without the new --bs-*-rgb variables. As a result, choosing a predefined scheme like dxpr-scheme-aivibe still leaves Bootstrap 5.3 utilities such as .text-primary, .link-primary, .focus-ring-primary, and .bg-body-secondary on Bootstrap's default colors.

Relevant code:

  • features/sooper-colors/colors-theme-settings-css.inc:78-96
  • scss/base/variables.scss:720-749
  • css/base/variables.css

@jjroelofs

Copy link
Copy Markdown
Collaborator Author

Fixed in beb654b. Added --bs-*-rgb generation inside the @each $name, $scheme loop in scss/base/variables.scss, using the same color.red()/color.green()/color.blue() approach already used for header-rgb. All 11 -rgb variables are now generated for every preset scheme alongside the existing hex --bs-* overrides. Rebuilt CSS artifact included.

Jurriaan Roelofs added 3 commits May 18, 2026 12:33
Bootstrap 5.3 utility classes like .text-primary, .bg-primary, and
.border-primary use the -rgb triplet form of CSS custom properties
(e.g. --bs-primary-rgb: 13, 110, 253) rather than the hex form
(--bs-primary). We overrode the hex variants but none of the 19 -rgb
variants, causing these utilities to ignore the theme palette.

Generate --bs-*-rgb companions from palette hex values using the
existing Color::hexToRgb() utility.

Fixes #812
The previous commit added -rgb variable generation for the custom
palette (PHP-generated CSS) but preset schemes defined in SCSS were
still missing them. Bootstrap 5.3 utility classes like .text-primary
and .bg-primary consume the -rgb triplet form, so preset schemes
like aivibe, brighthealthy, etc. also need these overrides.

Generate --bs-*-rgb variables from Sass color values inside the
@each scheme loop alongside the existing header-rgb extraction.

Fixes #812
Use multi-line } @else if { format to satisfy both
at-rule-empty-line-before and scss/at-else-closing-brace rules.
@jjroelofs jjroelofs force-pushed the jur/8.x/812-add-bs-rgb-variable-overrides branch from 1815ff7 to f2b1dad Compare May 18, 2026 10:34
@jjroelofs jjroelofs merged commit a2b909f into 8.x May 18, 2026
5 checks passed
@jjroelofs jjroelofs deleted the jur/8.x/812-add-bs-rgb-variable-overrides branch May 18, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant