Build and extend in real-time with CSS variables

Bootstrap 5 is evolving with each release to better utilize CSS variables for global theme styles, individual components, and even utilities. We provide dozens of variables for colors, font styles, and more at a :root level for use anywhere. On components and utilities, CSS variables are scoped to the relevant class and can easily be modified.

Learn more about CSS variables

Using CSS variables

Use any of our global :root variables to write new styles. CSS variables use the var(--bs-variableName) syntax and can be inherited by children elements.

{{ highlight (printf `.component { color: var(--bs-gray-800); background-color: var(--bs-gray-100); border: 1px solid var(--bs-gray-200); border-radius: .25rem; } .component-header { color: var(--bs-purple); }`) "scss" "" }}

Customizing via CSS variables

Override global, component, or utility class variables to customize Bootstrap just how you like. No need to redeclare each rule, just a new variable value.

{{ highlight (printf `body { --bs-body-font-family: var(--bs-font-monospace); --bs-body-line-height: 1.4; --bs-body-bg: var(--bs-gray-100); } .table { --bs-table-color: var(--bs-gray-600); --bs-table-bg: var(--bs-gray-100); --bs-table-border-color: transparent; }`) "scss" "" }}