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
🌐
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.
🌐
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...
Find elsewhere
🌐
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.
🌐
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";
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

🌐
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 › 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.
🌐
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
🌐
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); }
🌐
Initial Apps
initialapps.com › customizing-bootstrap-5-with-sass
Customizing bootstrap 5 with Sass! Example provided.
July 1, 2023 - An example for how to create custom theme color pallets in Bootstrap 5 using Sass. This post focuses on Bootstrap's color mapping functionality.
🌐
PureCode AI
blogs.purecode.ai › home › how to use bootstrap colors and make your ui pop
How to Use Bootstrap Colors and Make Your UI Pop - Blogs
September 29, 2025 - Bootstrap allows you to customize the core palette or even build your own easily. Imagine swapping primary for a deep purple to create a unique brand identity. Class-based Convenience: Forget messy inline styles.
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › customize › css-variables
CSS variables · Bootstrap v5.0
:root { --bs-blue: #0d6efd; --bs-indigo: #6610f2; --bs-purple: #6f42c1; --bs-pink: #d63384; --bs-red: #dc3545; --bs-orange: #fd7e14; --bs-yellow: #ffc107; --bs-green: #198754; --bs-teal: #20c997; --bs-cyan: #0dcaf0; --bs-white: #fff; --bs-gray: #6c757d; --bs-gray-dark: #343a40; --bs-primary: #0d6efd; --bs-secondary: #6c757d; --bs-success: #198754; --bs-info: #0dcaf0; --bs-warning: #ffc107; --bs-danger: #dc3545; --bs-light: #f8f9fa; --bs-dark: #212529; --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple