Are you ready for Cyber Week Deals?

Up to 70% discount for CoreUI PRO Admin Templates and UI Components.

This year we prepared a limited Cyber Week offer for our clients and users. The first 100 people can get our products with up to 70% discount.

CSS variables

Use CoreUI's CSS custom properties for fast and forward-looking design and development.

CoreUI includes around two dozen CSS custom properties (variables) in its compiled CSS, with dozens more on the way for improved customization on a per-component basis. 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 cui- 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 CoreUI's CSS is loaded. They're located in our _root.scss file and included in our compiled dist files.

1:root {
2 --cui-blue: #0d6efd;
3 --cui-indigo: #6610f2;
4 --cui-purple: #6f42c1;
5 --cui-pink: #d63384;
6 --cui-red: #dc3545;
7 --cui-orange: #fd7e14;
8 --cui-yellow: #ffc107;
9 --cui-green: #198754;
10 --cui-teal: #20c997;
11 --cui-cyan: #0dcaf0;
12 --cui-black: #000015;
13 --cui-white: #fff;
14 --cui-gray: #8a93a2;
15 --cui-gray-dark: #636f83;
16 --cui-gray-100: #ebedef;
17 --cui-gray-200: #d8dbe0;
18 --cui-gray-300: #c4c9d0;
19 --cui-gray-400: #b1b7c1;
20 --cui-gray-500: #9da5b1;
21 --cui-gray-600: #8a93a2;
22 --cui-gray-700: #768192;
23 --cui-gray-800: #636f83;
24 --cui-gray-900: #4f5d73;
25 --cui-primary: #321fdb;
26 --cui-secondary: #9da5b1;
27 --cui-success: #2eb85c;
28 --cui-info: #39f;
29 --cui-warning: #f9b115;
30 --cui-danger: #e55353;
31 --cui-light: #ebedef;
32 --cui-dark: #4f5d73;
33 --cui-primary-rgb: 50, 31, 219;
34 --cui-secondary-rgb: 157, 165, 177;
35 --cui-success-rgb: 46, 184, 92;
36 --cui-info-rgb: 51, 153, 255;
37 --cui-warning-rgb: 249, 177, 21;
38 --cui-danger-rgb: 229, 83, 83;
39 --cui-light-rgb: 235, 237, 239;
40 --cui-dark-rgb: 79, 93, 115;
41 --cui-white-rgb: 255, 255, 255;
42 --cui-black-rgb: 0, 0, 21;
43 --cui-body-color-rgb: 44, 56, 74;
44 --cui-body-bg-rgb: 255, 255, 255;
45 --cui-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";
46 --cui-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
47 --cui-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
48 --cui-body-font-family: var(--cui-font-sans-serif);
49 --cui-body-font-size: 1rem;
50 --cui-body-font-weight: 400;
51 --cui-body-line-height: 1.5;
52 --cui-body-color: rgba(44, 56, 74, 0.95);
53 --cui-body-bg: #fff;
54 --cui-border-width: 1px;
55 --cui-border-style: solid;
56 --cui-border-color: #d8dbe0;
57 --cui-border-color-translucent: rgba(0, 0, 21, 0.175);
58 --cui-border-radius: 0.375rem;
59 --cui-border-radius-sm: 0.25rem;
60 --cui-border-radius-lg: 0.5rem;
61 --cui-border-radius-xl: 1rem;
62 --cui-border-radius-2xl: 2rem;
63 --cui-border-radius-pill: 50rem;
64 --cui-heading-color: unset;
65 --cui-link-color: #321fdb;
66 --cui-link-hover-color: #2819af;
67 --cui-code-color: #d63384;
68 --cui-highlight-bg: #fff3cd;
69}

Component variables#

CoreUI 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 CoreUI components after Sass compilation.

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 cui- (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.

1body {
2 font: 1rem/1.5 var(--cui-font-sans-serif);
3}
4a {
5 color: var(--cui-blue);
6}

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 mean time, you can use these variables in other CSS situations, as well as in your JavaScript.