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.

Answer from Carol Skelly on Stack Overflow
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › customize › color
Color · Bootstrap v5.0
As shown below, we’ve added three contrast ratios to each of the main colors—one for the swatch’s current colors, one for against white, and one for against black. ... Sass cannot programmatically generate variables, so we manually created variables for every tint and shade ourselves. We specify the midpoint value (e.g., $blue-500) and use custom color functions to tint (lighten) or shade (darken) our colors via Sass’s mix() color function.
🌐
Bootstrap
getbootstrap.com › docs › 5.3 › customize › color
Color · Bootstrap v5.3
The utilities are built with the color’s associated CSS variables, and since we customize those CSS variables for dark mode, they are also adaptive to color mode by default. ... <div class="p-3 text-primary-emphasis bg-primary-subtle border border-primary-subtle rounded-3"> Example element with utilities </div> 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.
🌐
Bootstrap
getbootstrap.com › docs › 4.0 › getting-started › theming
Theming Bootstrap · Bootstrap
To modify an existing color in our $theme-colors map, add the following to your custom Sass file: $theme-colors: ( "primary": #0074d9, "danger": #ff4136 ); To add a new color to $theme-colors, add the new key and value: ... Bootstrap assumes ...
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.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. // Required @import "functions"; @import "variables"; @import "variables-dark"; // Add a custom color to $theme-colors $custom-colors: ( "custom-color": #7
🌐
Themes
bootstrap.themes.guide › how-to-customize-bootstrap.html
How to Customize Bootstrap
2. In your custom.scss, import the Bootstrap files that are needed for the overrides. (Usually, this is just variables.scss. In some cases, with more complex cutomizations, you may also need the functions, mixins, and other Bootstrap files.). Make the changes, then @import "bootstrap". It's important to import Bootstrap after the changes. For example, let’s change the body background-color to light-gray #eeeeee, and change the blue primary contextual color to Bootstrap's $purple variable...
🌐
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.
Find elsewhere
🌐
Bootstrap
getbootstrap.com › docs › 5.1 › customize › color
Color · Bootstrap v5.1
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.2 › customize › color
Color · Bootstrap v5.2
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.
🌐
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";
🌐
Medium
uxplanet.org › how-to-customize-bootstrap-b8078a011203
How to Customize Bootstrap. Custom themes for Bootstrap 4 with CSS… | by Carol Skelly | UX Planet
April 9, 2019 - When making customizations, you need to understand CSS Specificity. Overrides in thecustom.css need to use selectors that are as specific as the bootstrap.css. For example, here’s the CSS for Bootstrap 4 nav-link shown on a dark background Navbar (.navbar-dark .navbar-nav): .navbar-dark .navbar-nav .nav-link { color: rgba(255, 255, 255, 0.5); }
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

🌐
HubSpot
blog.hubspot.com › website › how-to-override-bootstrap-css
How to Edit, Customize, and Override Bootstrap CSS to Suit Your Brand
October 8, 2021 - And if you wanted to add a new color to the $theme-colors map, then you’d add a new key, use the variable “custom-color”, and assign it a value. The following would add a crimson red to the map.
🌐
Bootstrap
getbootstrap.com › docs › 4.0 › utilities › colors
Colors · Bootstrap
Convey meaning through color with a handful of color utility classes. Includes support for styling links with hover states, too.
🌐
Bootstrapcolors
bootstrapcolors.com
Bootstrap Color Theme Generator
So you're bored of the default bootstrap color themes? Create your own! Get your CSS file with custom colored: button (btn-) with matching hover, active and disabled states link (link-) with matching hover state text (text-) if you want colored text :) alert with matching text and link color list group item (list-group-item-) with matching font color and hover state background (bg-) that can be used anywhere (e.g.
🌐
Bootstrap
getbootstrap.com › docs › 5.3 › customize › overview
Customize · Bootstrap v5.3
Color modes Explore our default light mode and the new dark mode, or create custom color modes yourself. Components Learn how we build nearly all our components responsively and with base and modifier classes. CSS variables Use Bootstrap’s CSS custom properties for fast and forward-looking design and development.
🌐
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
🌐
Bootstrapclasses
bootstrapclasses.com › customize-bootstrap-colors
How to Customize Bootstrap Colors 2025 - Bootstrap CSS Classes Cheat Sheets
February 19, 2024 - If you are linking to a pre-compiled version of Bootstrap I recommend looking at the raw source and using search and replace in your code text editor to replace all of the color values. Then save this new stylesheet in your project folder and link to your customized version instead of the CDN version.