CSS variables
Use Bootstrap’s CSS custom properties for fast and forward-looking design and development.
Bootstrap includes many CSS custom properties (variables) in its compiled CSS for real-time customization without the need to recompile Sass. These provide easy access to commonly used values like our theme colors, breakpoints, and primary font stacks when working in your browser’s inspector, a code sandbox, or general prototyping.
All our custom properties are prefixed with bs-
to avoid conflicts with third party CSS.
Root variables
Here are the variables we include (note that the :root
is required) that can be accessed anywhere Bootstrap’s CSS is loaded. They’re located in our _root.scss
file and included in our compiled dist files.
:root {
--bs-blue: #002b5c;
--bs-indigo: #0171bc;
--bs-purple: #6f42c1;
--bs-pink: #d63384;
--bs-red: #c10520;
--bs-orange: #fd7e14;
--bs-yellow: #f7d068;
--bs-green: #228736;
--bs-teal: #20c997;
--bs-cyan: #0057b8;
--bs-skyblue: #d9edf7;
--bs-black: #000;
--bs-white: #fff;
--bs-gray: #545454;
--bs-gray-dark: #262626;
--bs-gray-100: #f2f2f2;
--bs-gray-200: #e0e0e0;
--bs-gray-300: #cccccc;
--bs-gray-400: #999999;
--bs-gray-500: #666666;
--bs-gray-600: #545454;
--bs-gray-700: #404040;
--bs-gray-800: #262626;
--bs-gray-900: #171717;
--bs-primary: #002b5c;
--bs-secondary: #0171bc;
--bs-success: #228736;
--bs-info: #0057b8;
--bs-warning: #f7d068;
--bs-danger: #c10520;
--bs-light: #f2f2f2;
--bs-dark: #404040;
--bs-maricopa-blue: #002b5c;
--bs-cgc-primary: #00818a;
--bs-cgc-secondary: #626367;
--bs-emc-primary: #642667;
--bs-emc-secondary: #d2a36a;
--bs-gcc-primary: #cb333b;
--bs-gcc-secondary: #2d2926;
--bs-gwc-primary: #0032a1;
--bs-gwc-secondary: #af282f;
--bs-mcc-primary: #004c97;
--bs-mcc-secondary: #bf0d3e;
--bs-pcc-primary: #00305d;
--bs-pcc-secondary: #ffc845;
--bs-pvc-primary: #003da5;
--bs-pvc-secondary: #d9c89e;
--bs-rsc-primary: #236192;
--bs-rsc-secondary: #FFCA28;
--bs-scc-primary: #215732;
--bs-scc-secondary: #ffb81c;
--bs-smc-primary: #ad6500;
--bs-smc-secondary: #050505;
--bs-primary-rgb: 0, 43, 92;
--bs-secondary-rgb: 1, 113, 188;
--bs-success-rgb: 34, 135, 54;
--bs-info-rgb: 0, 87, 184;
--bs-warning-rgb: 247, 208, 104;
--bs-danger-rgb: 193, 5, 32;
--bs-light-rgb: 242, 242, 242;
--bs-dark-rgb: 64, 64, 64;
--bs-maricopa-blue-rgb: 0, 43, 92;
--bs-cgc-primary-rgb: 0, 129, 138;
--bs-cgc-secondary-rgb: 98, 99, 103;
--bs-emc-primary-rgb: 100, 38, 103;
--bs-emc-secondary-rgb: 210, 163, 106;
--bs-gcc-primary-rgb: 203, 51, 59;
--bs-gcc-secondary-rgb: 45, 41, 38;
--bs-gwc-primary-rgb: 0, 50, 161;
--bs-gwc-secondary-rgb: 175, 40, 47;
--bs-mcc-primary-rgb: 0, 76, 151;
--bs-mcc-secondary-rgb: 191, 13, 62;
--bs-pcc-primary-rgb: 0, 48, 93;
--bs-pcc-secondary-rgb: 255, 200, 69;
--bs-pvc-primary-rgb: 0, 61, 165;
--bs-pvc-secondary-rgb: 217, 200, 158;
--bs-rsc-primary-rgb: 35, 97, 146;
--bs-rsc-secondary-rgb: 255, 202, 40;
--bs-scc-primary-rgb: 33, 87, 50;
--bs-scc-secondary-rgb: 255, 184, 28;
--bs-smc-primary-rgb: 173, 101, 0;
--bs-smc-secondary-rgb: 5, 5, 5;
--bs-white-rgb: 255, 255, 255;
--bs-black-rgb: 0, 0, 0;
--bs-body-color-rgb: 64, 64, 64;
--bs-body-bg-rgb: 255, 255, 255;
--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
--bs-body-font-family: Roboto, sans-serif;
--bs-body-font-size: 1rem;
--bs-body-font-weight: 400;
--bs-body-line-height: 1.5;
--bs-body-color: #404040;
--bs-body-bg: #fff;
--bs-border-width: 1px;
--bs-border-style: solid;
--bs-border-color: #cccccc;
--bs-border-color-translucent: rgba(0, 0, 0, 0.175);
--bs-border-radius: 0.3rem;
--bs-border-radius-sm: 0.2rem;
--bs-border-radius-lg: 0.4rem;
--bs-border-radius-xl: 0.9rem;
--bs-border-radius-2xl: 2rem;
--bs-border-radius-pill: 50rem;
--bs-link-color: #0171bc;
--bs-link-hover-color: #0060A0;
--bs-code-color: #d63384;
--bs-highlight-bg: #fdf6e1;
}
Component variables
Bootstrap 5 is increasingly making use of custom properties as local variables for various components. This way we reduce our compiled CSS, ensure styles aren’t inherited in places like nested tables, and allow some basic restyling and extending of Bootstrap components after Sass compilation.
Have a look at our table documentation for some insight into how we’re using CSS variables. Our navbars also use CSS variables as of v5.2.0.
Whenever possible, we’ll assign CSS variables at the base component level (e.g., .navbar
for navbar and its sub-components). This reduces guessing on where and how to customize, and allows for easy modifications by our team in future updates.
Prefix
Most CSS variables use a prefix to avoid collisions with your own codebase. This prefix is in addition to the --
that’s required on every CSS variable.
Customize the prefix via the $prefix
Sass variable. By default, it’s set to bs-
(note the trailing dash).
Examples
CSS variables offer similar flexibility to Sass’s variables, but without the need for compilation before being served to the browser. For example, here we’re resetting our page’s font and link styles with CSS variables.
body {
font: 1rem/1.5 var(--bs-font-sans-serif);
}
a {
color: var(--bs-blue);
}
Grid breakpoints
While we include our grid breakpoints as CSS variables (except for xs
), be aware that CSS variables do not work in media queries. This is by design in the CSS spec for variables, but may change in coming years with support for env()
variables. Check out this Stack Overflow answer for some helpful links. In the meantime, you can use these variables in other CSS situations, as well as in your JavaScript.