Bootstrap 5.1.0

A recent change to the way the text- and bg- classes are created requires additional SASS map merges in 5.1.0

@import "functions";
@import "variables";
@import "mixins";

$tertiary: #3fb247;

$custom-theme-colors:map-merge($theme-colors, (
  "tertiary": $tertiary
));

$theme-colors: map-merge($theme-colors, $custom-theme-colors);
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
$utilities-colors: map-merge($utilities-colors, $theme-colors-rgb);
$utilities-text-colors: map-loop($utilities-colors, rgba-css-var, "$key", "text");
$utilities-bg-colors: map-loop($utilities-colors, rgba-css-var, "$key", "bg");

@import "bootstrap";

Bootstrap 5.0.2

You need to add a "tertiary" var to the theme-colors map using map-merge if you want it to generate classes like bg-tertiary, btn-tertiary, etc...

@import "functions";
@import "variables";
@import "mixins";

$tertiary: #3fb247;

$theme-colors:map-merge($theme-colors, (
  "tertiary": $tertiary
));
      
@import "bootstrap";

Demo

Answer from Carol Skelly on Stack Overflow
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › customize › color
Color · Bootstrap v5.0
$theme-colors: ( "primary": $primary, "secondary": $secondary, "success": $success, "info": $info, "warning": $warning, "danger": $danger, "light": $light, "dark": $dark ); Check out our Sass maps and loops docs for how to modify these colors. All Bootstrap colors are available as Sass variables and a Sass map in scss/_variables.scss file.
🌐
Bootstrap
getbootstrap.com › docs › 5.3 › customize › color
Color · Bootstrap v5.3
We use a subset of all colors to create a smaller color palette for generating color schemes, also available as Sass variables and a Sass map in Bootstrap’s scss/_variables.scss file. ... All these colors are available as a Sass map, $theme-colors.
🌐
Bootstrap
getbootstrap.com › docs › 5.3 › customize › color-modes
Color modes · Bootstrap v5.3
New colors must also be defined in $theme-colors-text, $theme-colors-bg-subtle, and $theme-colors-border-subtle for light theme; but also in $theme-colors-text-dark, $theme-colors-bg-subtle-dark, and $theme-colors-border-subtle-dark for dark theme. This is a manual process because Sass cannot generate its own Sass variables from an existing variable or map. In future versions of Bootstrap, we'll revisit this setup to reduce the duplication.
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › utilities › colors
Colors · Bootstrap v5.0
"color": ( property: color, class: text, values: map-merge( $theme-colors, ( "white": $white, "body": $body-color, "muted": $text-muted, "black-50": rgba($black, .5), "white-50": rgba($white, .5), "reset": inherit, ) ) ),
🌐
Huemint
huemint.com › bootstrap-basic
Huemint - Generate a color palette for your bootstrap theme
Add this to your custom.scss file to override the default bootstrap colors - add this before @import "bootstrap"; $white: ; $theme-colors: ( "light": , "dark": , "primary": , "secondary": , "info": , "success": , "warning": , "danger": , );
🌐
MDBootstrap
mdbootstrap.com › standard › colors
Bootstrap 5 Colors - free examples & tutorial
Colors for the latest Bootstrap 5. Color picker, style form, colors palette, hex, guide & many more.
Top answer
1 of 5
50

Bootstrap 5.1.0

A recent change to the way the text- and bg- classes are created requires additional SASS map merges in 5.1.0

@import "functions";
@import "variables";
@import "mixins";

$tertiary: #3fb247;

$custom-theme-colors:map-merge($theme-colors, (
  "tertiary": $tertiary
));

$theme-colors: map-merge($theme-colors, $custom-theme-colors);
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
$utilities-colors: map-merge($utilities-colors, $theme-colors-rgb);
$utilities-text-colors: map-loop($utilities-colors, rgba-css-var, "$key", "text");
$utilities-bg-colors: map-loop($utilities-colors, rgba-css-var, "$key", "bg");

@import "bootstrap";

Bootstrap 5.0.2

You need to add a "tertiary" var to the theme-colors map using map-merge if you want it to generate classes like bg-tertiary, btn-tertiary, etc...

@import "functions";
@import "variables";
@import "mixins";

$tertiary: #3fb247;

$theme-colors:map-merge($theme-colors, (
  "tertiary": $tertiary
));
      
@import "bootstrap";

Demo

2 of 5
10

As of Bootstrap 5.1.3 the background color component is not automatically generated by

$utilities-bg-colors: map-loop($utilities-colors, rgba-css-var, "$key", "bg");

In the manual it is written,

Unfortunately at this time, not every component utilizes this Sass map. Future updates will strive to improve upon this. Until then, plan on making use of the ${color} variables and this Sass map.

Here is one way of manually adding .bg-* classes in Bootstrap 5.1.3. Compiled with Parcel V 2.3.2

/*Bootstrap core imports - adjust for your case*/
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/utilities";
@import "~bootstrap/scss/mixins";


$custom-theme-colors:(
  "custom-color": #8bd0da,
);

$theme-colors: map-merge($theme-colors, $custom-theme-colors);
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
$utilities-colors: map-merge($utilities-colors, $theme-colors-rgb);
$utilities-text-colors: map-loop($utilities-colors, rgba-css-var, "$key", "text");
$utilities-bg-colors: map-loop($utilities-colors, rgba-css-var, "$key", "bg");

// Adjust path to bootstrap for your case
@import "~bootstrap/scss/bootstrap";

// .bg classes not automatically generated. As an example, manually add
// .bg-custom-color

.bg-custom-color{background-color: var(--bs-custom-color);};

Example html

<div class="container border mb-4 bg-primary">
    Background: bg-primary
</div>

<div class="container border mb-4 bg-custom-color">
    <code>bg-custom-color</code>
</div>

<div class="container mb-4">    
    <div class="btn btn-custom-color"><code>btn-custom-color</code></div>
</div>

<div class="container mb-4">
    <div class="alert-custom-color">alert-custom-color</div>
</div>

<div class="container mb-4">
    <ul class="list-group">
        <li class="list-group-item-custom-color"><code>list-group-item-custom-color</code></li>
    </ul>
</div>

The page render as shown below

🌐
Colormind
colormind.io › bootstrap
Colormind - Bootstrap UI colors
Generate color schemes for a bootstrap theme. See how it looks immediately with our bootstrap UI kit
Find elsewhere
🌐
Bootstrapcolors
bootstrapcolors.com
Bootstrap Color Theme Generator
Many CSS frameworks such as Tailwind ... to include more colors that are present in different shades such as $blue-100, $blue-200, $blue-300, …., $blue-900....
🌐
Assistancy
blog.assistancy.be › blog › bootstrap-5-override-theme-colors-sass
Discover how to override theme colors in Bootstrap 5 using Sass • Assistancy
May 13, 2025 - Thus, make sure to include also the defaults when you override $theme-colors in v5.0.0-beta2. That is, if you need those defaults of course.Steven · We illustrate with an example below. Many more similar declarations are present in _variables.scss. //Bootstrap v4.5.3 $link-color: theme-color("primary") !default; //Bootstrap v5 $link-color: $primary !default;
🌐
MDBootstrap
mdbootstrap.com › standard › color modes
Bootstrap 5 Color modes - free examples & tutorial
With v7.0.0 you can implement your own color mode toggler (see below for an example) and apply the different color modes as you see fit. We support a light mode (default) and now dark mode. Color modes can be toggled globally on the <html> element, or on specific components and elements, thanks to the data-mdb-theme attribute.
🌐
Initial Apps
initialapps.com › customizing-bootstrap-5-with-sass
Customizing bootstrap 5 with Sass! Example provided.
July 1, 2023 - // 4. Include any default map overrides here // Create your own map $custom-colors: ( "dark-lava": #4B4237, "goldenrod": #D5A021, "alabaster": #EDE7D9, "spanish-gray": #A49694, "dim-gray": #736B60, "purple-100": $purple-100, "blue-200": $blue-200, "pink": $pink, "teal-800": $teal-800, ); // Merge the maps $theme-colors: map-merge($theme-colors, $custom-colors); Notice, since we use this function after loading the bootstrap variables, we can just add the extra color variables to our custom colors. ... Hope this helps you get started setting up Sass on Bootstrap 5!
🌐
W3Schools
w3schools.com › bootstrap5 › bootstrap_colors.php
Bootstrap 5 Colors
Light grey background color. Try it Yourself » ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected] · If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected] · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
Bootstrap
getbootstrap.com › docs › 4.5 › getting-started › theming
Theming Bootstrap · Bootstrap v4.5
Many of Bootstrap’s components are built with a base-modifier class approach. This means the bulk of the styling is contained to a base class (e.g., .btn) while style variations are confined to modifier classes (e.g., .btn-danger). These modifier classes are built from the $theme-colors map to make customizing the number and name of our modifier classes.
🌐
Bootswatch
bootswatch.com
Bootswatch: Free themes for Bootstrap
Simply download a CSS file and replace the one in Bootstrap. No messing around with hex values. Changes are contained in just two SASS files, enabling further customization and ensuring forward compatibility. Themes are built for the latest version of Bootstrap.
🌐
Bootstrap
getbootstrap.com › docs › 5.3 › utilities › colors
Colors · Bootstrap v5.3
Grayscale colors are also available, but only a subset are used to generate any utilities. ... $white: #fff; $gray-100: #f8f9fa; $gray-200: #e9ecef; $gray-300: #dee2e6; $gray-400: #ced4da; $gray-500: #adb5bd; $gray-600: #6c757d; $gray-700: #495057; $gray-800: #343a40; $gray-900: #212529; $black: #000; ... $theme-colors-text: ( "primary": $primary-text-emphasis, "secondary": $secondary-text-emphasis, "success": $success-text-emphasis, "info": $info-text-emphasis, "warning": $warning-text-emphasis, "danger": $danger-text-emphasis, "light": $light-text-emphasis, "dark": $dark-text-emphasis, );
Top answer
1 of 16
240

Bootstrap 5.3 (update 2023)

Here's an example using an existing color variable ($orange).

// required to get $orange variable
@import "functions"; 
@import "variables";

$primary: $orange; // set the $primary variable

// merge with existing $theme-colors map
$theme-colors: map-merge($theme-colors, (
  "primary": $primary
));

// set changes
@import "bootstrap";

https://codeply.com/p/qFez3k8oIF

Bootstrap 5 (update 2021)

The SASS override method is still the same for Bootstrap 5. If you're not referencing any existing Bootstrap variables to set the the new colors, you just need to set the theme variable(s) and @import bootstrap

$primary: rebeccapurple;

@import "bootstrap"; //use full path to bootstrap.scss

https://codeply.com/p/iauLPArGqE

Bootstrap 4*

To change the primary, or any of the theme colors in Bootstrap 4 SASS, set the appropriate variables before importing bootstrap.scss. This allows your custom scss to override the !default values...

$primary: purple;
$danger: red;

@import "bootstrap";

Demo: https://codeply.com/go/f5OmhIdre3


In some cases, you may want to set a new color from another existing Bootstrap variable. For this @import the functions and variables first so they can be referenced in the customizations...

/* import the necessary Bootstrap files */
@import "bootstrap/functions";
@import "bootstrap/variables";

$theme-colors: (
  primary: $purple
);

/* finally, import Bootstrap */
@import "bootstrap";

Demo: https://codeply.com/go/lobGxGgfZE


Also see: this answer, this answer or changing the button color in (CSS or SASS)


It's also possible to change the primary color with CSS only but it requires a lot of additional CSS since there are many -primary variations (btn-primary, alert-primary, bg-primary, text-primary, table-primary, border-primary, etc...) and some of these classes have slight colors variations on borders, hover, and active states. Therefore, if you must use CSS it's better to use target one component such as changing the primary button color.

2 of 16
48

I've created this tool: https://lingtalfi.com/bootstrap4-color-generator, you simply put primary in the first field, then choose your color, and click generate.

Then copy the generated scss or css code, and paste it in a file named my-colors.scss or my-colors.css (or whatever name you want).

Once you compile the scss into css, you can include that css file AFTER the bootstrap CSS and you'll be good to go.

The whole process takes about 10 seconds if you get the gist of it, provided that the my-colors.scss file is already created and included in your head tag.

Note: this tool can be used to override bootstrap's default colors (primary, secondary, danger, ...), but you can also create custom colors if you want (blue, green, ternary, ...).

Note2: this tool was made to work with bootstrap 4 (i.e. not any subsequent version for now).

🌐
Bootstrap
getbootstrap.com › docs › 5.0 › customize › overview
Customize · Bootstrap v5.0
Learn how to theme, customize, and extend Bootstrap with Sass, a boatload of global options, an expansive color system, and more.
🌐
GitHub
github.com › twbs › bootstrap › issues › 34680
[5.1.0] Adding colors to $theme-colors no longer works · Issue #34680 · twbs/bootstrap
August 4, 2021 - Windows 10 Chrome 92.0.4515.107 Bootstrap 5.1.0 Previously (in 5.0.2), I used the following code to add custom colors to $theme-colors: @import "node_modules/bootstrap/scss/functions"; @import "node_modules/bootstrap/scss/variables"; $th...
Published   Aug 04, 2021