Sass reaches every component; --bs-primary alone does not recolor buttons or .bg-primary

How to change Bootstrap theme colors

To change Bootstrap 5.3 theme colors across every component, set $primary, $secondary and the other theme colors in your own Sass file before Bootstrap's variables are imported. To make changes without Sass, override --bs-primary along with its --bs-primary-rgb channels, link colors and .btn-primary variables in a stylesheet loaded after Bootstrap's. You can preview palettes directly on your site before changing code by loading your page into the Recolor app at Recolor (recolor.page) and pressing Space.

Last updated

Bootstrap 5.3's color, Sass, CSS variables, buttons and utilities docs (v5.3.9) and its _variables.scss, read 14 Nov 2026
Where you set itWhat you setWhat follows
Sass, after functions and before variables$primary, $secondary and the other theme colorsButtons with their hover and active shades, links, .bg-* and .text-*, the subtle and emphasis colors
CSS, after Bootstrap's stylesheet--bs-primary and --bs-primary-rgb.bg-primary and .text-primary, which read the -rgb channel numbers
CSS, on .btn-primary--bs-btn-bg, --bs-btn-border-color, --bs-btn-color and their hover and active formsThe buttons, whose values Bootstrap sets through Sass
CSS, on :root--bs-link-color, --bs-link-hover-color and their -rgb formsLinks
The data-bs-theme="dark" attributeThe dark color mode, from _variables-dark.scss in SassEvery component inside it

Sass reaches everything

Bootstrap's Sass docs say variable overrides come after its functions are imported and before the rest. $primary feeds the $theme-colors map, $link-color is $primary by default, and _variables.scss makes $primary-bg-subtle, $primary-border-subtle and $primary-text-emphasis from it. The button mixin derives the hover and active shades and picks each button's text with color-contrast(), which tries to reach $min-contrast-ratio, 4.5 by default.

The theme colors are primary, secondary, success, info, warning, danger, light and dark. The Sass docs warn that replacing them is fine but removing primary, success or danger can break compilation. Recolor's palette has no accent in Bootstrap's list: map $color-accent to one of those names by hand, or leave it out.

SCSS
// custom.scss
// Required
@import "../node_modules/bootstrap/scss/functions";

// Default variable overrides: Recolor's SCSS export, then Bootstrap's names
$color-1: #264653;
$color-2: #2a9d8f;
$color-3: #e9c46a;
$color-4: #f4a261;
$color-5: #e76f51;
$color-primary: $color-1;
$color-secondary: $color-2;
$color-accent: $color-3;

$primary: $color-primary;
$secondary: $color-secondary;

// Required
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/variables-dark";
@import "../node_modules/bootstrap/scss/maps";
@import "../node_modules/bootstrap/scss/mixins";
@import "../node_modules/bootstrap/scss/root";

// Optional Bootstrap components here
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
// etc

The CSS variables, and what they miss

Bootstrap's CSS variables docs offer --bs-primary and the rest for changes without recompiling Sass. --bs-primary alone changes little: .bg-primary and .text-primary read --bs-primary-rgb, channel numbers such as 38, 70, 83, and Bootstrap's buttons docs say button values are set through Sass on .btn-primary's own variables.

Set both color formats and the button variables in your stylesheet:

CSS
/* custom.css, loaded after bootstrap.min.css */
:root {
  --bs-primary: #264653;
  --bs-primary-rgb: 38, 70, 83;
  --bs-secondary: #2a9d8f;
  --bs-secondary-rgb: 42, 157, 143;
  --bs-link-color: #264653;
  --bs-link-color-rgb: 38, 70, 83;
}
.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: #264653;
  --bs-btn-border-color: #264653;
  --bs-btn-hover-color: #000;
  --bs-btn-hover-bg: #2a9d8f;
  --bs-btn-hover-border-color: #2a9d8f;
}

Dark mode is the data-bs-theme="dark" attribute on the html element or any other; its Sass overrides live in _variables-dark.scss.

Try the palette on your deployed site first

Paste the deployed address into Recolor and press Space; lock a color you keep with L. Recolor reads Bootstrap's compiled colors, the --bs-* variables and their -rgb channel numbers included (how it works).

Each swatch shows its contrast with black and white text, marked at 4.5:1: white on #264653 reads 10.08:1, while #2a9d8f reads 3.32:1 with white and 6.32:1 with black, under the 4.5 color-contrast() asks of white, so its Sass buttons get dark text and the CSS route above sets black on hover (read the black or white text guide; the contrast matrix gives every pair). A localhost address is refused: deploy a preview or upload the saved page. Images, video and canvas keep their colors. Bootstrap was on 13% of the 1,000 most-linked sites in Recolor's study, each listed by name.

Common questions

Does setting --bs-primary change Bootstrap's buttons?

No. Buttons read .btn-primary's --bs-btn-* variables; set those too, or use Sass.

Do I need --bs-primary-rgb as well as --bs-primary?

Yes. The .bg-primary and .text-primary utilities read the -rgb channel numbers.

Can Recolor's SCSS export go straight into custom.scss?

Yes. Paste it after the functions import, then point $primary and $secondary at $color-primary and $color-secondary (check the export formats).

Does Bootstrap pick readable button text by itself?

Yes, in Sass: color-contrast() picks light or dark text, aiming at $min-contrast-ratio.

Can Recolor load my localhost dev server?

No. Recolor loads public addresses; deploy a preview or upload the saved page.

Is it free?

Yes. Loading a site, generating palettes and every export format are free, without an account, as shown on the pricing page.

Sources