Skip to main content
/
/
/
CSS Colors

CSS Colors

Color guide, naming conventions, usage and contrast rules

Bifrost consists of a defined set of colors that help us convey Intilitys identity and ensure the proper contrast for accessibility.

Text classes

The most used text colors have utility classes prefixed with .bfc-* for easier use. For base backgrounds you can use the following classes:

NameExample
.bfc-baseSample base text
.bfc-base-2Sample base-2 text
.bfc-disabledSample disabled text
.bfc-themeSample theme text
.bfc-brandSample brand text
.bfc-chillSample chill text
.bfc-attnSample attn text
.bfc-successSample success text
.bfc-warningSample warning text
.bfc-alertSample alert text

Background classes

Some color combinations with both a main color and its matching contrast color are also available, all with a *-bg suffix. These will also supply correct text color to nested links (like <a> elements and the .bf-link class).

NameExample
.bfc-base-bgbase sample with link
.bfc-base-2-bgbase-2 sample with link
.bfc-base-3-bgbase-3 sample with link
.bfc-dimmed-bgdimmed sample with link
.bfc-inverted-bginverted sample with link
.bfc-inverted-2-bginverted-2 sample with link
.bfc-disabled-bgdisabled sample with link
.bfc-theme-bgtheme sample with link
.bfc-theme-fade-bgtheme-fade sample with link
.bfc-neutral-bgneutral sample with link
.bfc-neutral-fade-bgneutral-fade sample with link
.bfc-brand-bgbrand sample with link
.bfc-brand-fade-bgbrand-fade sample with link
.bfc-attn-bgattn sample with link
.bfc-attn-fade-bgattn-fade sample with link
.bfc-chill-bgchill sample with link
.bfc-chill-fade-bgchill-fade sample with link
.bfc-success-bgsuccess sample with link
.bfc-success-fade-bgsuccess-fade sample with link
.bfc-warning-bgwarning sample with link
.bfc-warning-fade-bgwarning-fade sample with link
.bfc-alert-bgalert sample with link
.bfc-alert-fade-bgalert-fade sample with link

Variables

All bifrost components supports light and dark mode out of the box, and so will your project as long as you avoid using any color codes (like hex or hsl) directly. Always stick with the CSS variables as described below, and you're golden! :)

Most colors change completely between modes, click the icon in the top right corner to toggle between light and dark mode.

All colors are available as CSS custom properties (a.k.a. CSS variables), prefixed with --bfc- (which stands for bifrost colors).

For numbered color names, the -1 suffix can be omitted, which means:

  • base is the same as base-1
  • base-c is the same as base-c-1
  • theme is the same as theme-1 etc.
NameExample
--bfc-basebase
--bfc-base-2base-2
--bfc-base-3base-3
--bfc-base-cbase-c
--bfc-base-c-2base-c-2
--bfc-base-c-themebase-c-theme
--bfc-base-c-brandbase-c-brand
--bfc-base-c-chillbase-c-chill
--bfc-base-c-attnbase-c-attn
--bfc-base-c-successbase-c-success
--bfc-base-c-warningbase-c-warning
--bfc-base-c-alertbase-c-alert
--bfc-base-c-wcagbase-c-wcag
--bfc-base-c-disabledbase-c-disabled
--bfc-base-c-dimmedbase-c-dimmed
--bfc-base-dimmedbase-dimmed
--bfc-base-dimmed-2base-dimmed-2
--bfc-base-dimmed-3base-dimmed-3
--bfc-base-disabledbase-disabled
--bfc-base-c-invertedbase-c-inverted
--bfc-base-c-inverted-2base-c-inverted-2
--bfc-base-c-inverted-3base-c-inverted-3
--bfc-themetheme
--bfc-theme-2theme-2
--bfc-theme-3theme-3
--bfc-theme-ctheme-c
--bfc-theme-c-2theme-c-2
--bfc-theme-hctheme-hc
--bfc-theme-fadetheme-fade
--bfc-theme-fade-ctheme-fade-c
--bfc-neutralneutral
--bfc-neutral-cneutral-c
--bfc-neutral-hcneutral-hc
--bfc-neutral-fadeneutral-fade
--bfc-neutral-fade-cneutral-fade-c
--bfc-brandbrand
--bfc-brand-cbrand-c
--bfc-brand-hcbrand-hc
--bfc-brand-fadebrand-fade
--bfc-brand-fade-cbrand-fade-c
--bfc-chillchill
--bfc-chill-cchill-c
--bfc-chill-hcchill-hc
--bfc-chill-fadechill-fade
--bfc-chill-fade-cchill-fade-c
--bfc-attnattn
--bfc-attn-cattn-c
--bfc-attn-hcattn-hc
--bfc-attn-fadeattn-fade
--bfc-attn-fade-cattn-fade-c
--bfc-successsuccess
--bfc-success-csuccess-c
--bfc-success-hcsuccess-hc
--bfc-success-fadesuccess-fade
--bfc-success-fade-csuccess-fade-c
--bfc-warningwarning
--bfc-warning-cwarning-c
--bfc-warning-hcwarning-hc
--bfc-warning-fadewarning-fade
--bfc-warning-fade-cwarning-fade-c
--bfc-alertalert
--bfc-alert-2alert-2
--bfc-alert-calert-c
--bfc-alert-hcalert-hc
--bfc-alert-fadealert-fade
--bfc-alert-fade-calert-fade-c
--bfc-alert-fade-2alert-fade-2
--bfc-alert-fade-2-calert-fade-2-c

Color themes

New in 5.0

All color variables named --bfc-theme-* (and --bfc-base-c-theme) are teal-colored by default, but can be changed by using a .bf-theme-[color] color class. Currently available colors are:

  • .bf-theme-teal
  • .bf-theme-purple
  • .bf-theme-pink
  • .bf-theme-yellow

You can apply it globally to your entire app by adding a theme class to the root <html> element:

<html class="bf-theme-purple"> <!-- `--bfc-theme-*` variables are now purple for your entire app --> </html>
<html class="bf-theme-purple"> <!-- `--bfc-theme-*` variables are now purple for your entire app --> </html>

Or you can apply it to any individual element:

<div class="bf-theme-purple"> <!-- `--bfc-theme-*` variables are now purple for this element and descendants --> </div>
<div class="bf-theme-purple"> <!-- `--bfc-theme-*` variables are now purple for this element and descendants --> </div>

All theme variables

Variables that may change between color themes and light/dark mode. Some names are aliases (like theme-1 and theme).

varcurrenttealpurplepinkyellow
--bfc-base-c-theme
--bfc-theme
--bfc-theme-1
--bfc-theme-2
--bfc-theme-3
--bfc-theme-c
--bfc-theme-c-1
--bfc-theme-c-2
--bfc-theme-hc
--bfc-theme-fade
--bfc-theme-fade-c

Shadow

  • .bf-shadow class name applies a subtle box-shadow on an element.
    Equivalent to box-shadow: var(--bf-shadow)
  • --bf-shadow variable contains values for box-shadow css property.
    Equivalent to 0 0 8px var(--bfc-shadow)
  • --bfc-shadow variable contains the bifrost shadow color only. Slightly stronger in dark mode than light.
<div class="bf-shadow bf-padding bfc-base-3-bg">.bf-shadow</div> <div style="box-shadow: var(--bf-shadow)" class="bf-padding bfc-base-3-bg"> var(--bf-shadow) </div> <div style="box-shadow: 0 0 8px var(--bfc-shadow)" class="bf-padding bfc-base-3-bg" > 0 0 8px var(--bfc-shadow) </div> <div style="box-shadow: 0 4px 20px 5px var(--bfc-shadow)" class="bf-padding bfc-base-3-bg" > 0 4px 20px 5px var(--bfc-shadow) </div>
<div class="bf-shadow bf-padding bfc-base-3-bg">.bf-shadow</div> <div style="box-shadow: var(--bf-shadow)" class="bf-padding bfc-base-3-bg"> var(--bf-shadow) </div> <div style="box-shadow: 0 0 8px var(--bfc-shadow)" class="bf-padding bfc-base-3-bg" > 0 0 8px var(--bfc-shadow) </div> <div style="box-shadow: 0 4px 20px 5px var(--bfc-shadow)" class="bf-padding bfc-base-3-bg" > 0 4px 20px 5px var(--bfc-shadow) </div>
.bf-shadow
var(--bf-shadow)
0 0 8px var(--bfc-shadow)
0 4px 20px 5px var(--bfc-shadow)

base-3 on base-3 example:

.bf-shadow
0 4px 20px 5px var(--bfc-shadow)

base on base example:

.bf-shadow
0 4px 20px 5px var(--bfc-shadow)

If you need a drop shadow on a transparent image you can use filter: drop-shadow(var(--bf-shadow)).

Shadow position

There are also four CSS classes and variables available for positioned shadows

<div class="bf-padding bfc-base-3-bg bf-shadow-top">.bf-shadow-top</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-top)"> --bf-shadow-top </div> <div class="bf-padding bfc-base-3-bg bf-shadow-right">.bf-shadow-right</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-right)" > --bf-shadow-right </div> <div class="bf-padding bfc-base-3-bg bf-shadow-bottom">.bf-shadow-bottom</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-bottom)" > --bf-shadow-bottom </div> <div class="bf-padding bfc-base-3-bg bf-shadow-left">.bf-shadow-left</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-left)"> --bf-shadow-left </div>
<div class="bf-padding bfc-base-3-bg bf-shadow-top">.bf-shadow-top</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-top)"> --bf-shadow-top </div> <div class="bf-padding bfc-base-3-bg bf-shadow-right">.bf-shadow-right</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-right)" > --bf-shadow-right </div> <div class="bf-padding bfc-base-3-bg bf-shadow-bottom">.bf-shadow-bottom</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-bottom)" > --bf-shadow-bottom </div> <div class="bf-padding bfc-base-3-bg bf-shadow-left">.bf-shadow-left</div> <div class="bf-padding bfc-base-3-bg" style="box-shadow: var(--bf-shadow-left)"> --bf-shadow-left </div>
.bf-shadow-top
--bf-shadow-top
.bf-shadow-right
--bf-shadow-right
.bf-shadow-bottom
--bf-shadow-bottom
.bf-shadow-left
--bf-shadow-left

Opacity through hsla()

Some base colors are available as HSL values only, for example, in dark mode:

  • var(--bfc-theme) equals hsl(173, 88%, 50%) and can be used directly anywhere a css color is expected
  • var(--bfc-theme-hsl) equals 173, 88%, 50% and cannot be used as a color directly
  • hsl(var(--bfc-theme-hsl)) equals hsl(173, 88%, 50%) and is a valid color (but not very useful, same as just writing var(--bfc-theme))
  • hsla(var(--bfc-theme-hsl), 0.5) equals hsla(173, 88%, 50%, 0.5), a valid theme color with 50% opacity!
Accessibility

When using transparent colors it is up to you to make sure text is still readable, following WCAG standards!

For instance, use an eye-dropper tool to find the rendered color code (for both light and dark mode), then supply the colors to a contrast checker.

Don't forget to check for both light and dark mode individually.

Opacity examples

TransparentOpaque
base with 50% opacity
hsla(var(--bfc-base-hsl), 0.5)
base-dimmed with 50% opacity
hsla(var(--bfc-base-dimmed-hsl), 0.5)
theme with 50% opacity
hsla(var(--bfc-theme-hsl), 0.5)
theme-fade with 50% opacity
hsla(var(--bfc-theme-fade-hsl), 0.5)
brand with 50% opacity
hsla(var(--bfc-brand-hsl), 0.5)
brand-fade with 50% opacity
hsla(var(--bfc-brand-fade-hsl), 0.5)
chill with 50% opacity
hsla(var(--bfc-chill-hsl), 0.5)
chill-fade with 50% opacity
hsla(var(--bfc-chill-fade-hsl), 0.5)
attn with 50% opacity
hsla(var(--bfc-attn-hsl), 0.5)
attn-fade with 50% opacity
hsla(var(--bfc-attn-fade-hsl), 0.5)
success with 50% opacity
hsla(var(--bfc-success-hsl), 0.5)
success-fade with 50% opacity
hsla(var(--bfc-success-fade-hsl), 0.5)
warning with 50% opacity
hsla(var(--bfc-warning-hsl), 0.5)
warning-fade with 50% opacity
hsla(var(--bfc-warning-fade-hsl), 0.5)
alert with 50% opacity
hsla(var(--bfc-alert-hsl), 0.5)
alert-fade with 50% opacity
hsla(var(--bfc-alert-fade-hsl), 0.5)

Force light / dark mode

Bifrost will automatically switch between light and dark mode based on prefers-color-scheme (a.k.a. "System" or "OS setting"). This is the recommended behavior in almost all cases.

If you need to force dark mode, apply the .bf-darkmode class on <html> root element, or .bf-lightmode for light.

<html> Bifrost colors follow OS / Browser setting (prefers-color-scheme) </html> <html class="bf-lightmode"> Always light mode Bifrost colors </html> <html class="bf-darkmode"> Always dark mode Bifrost colors </html>
<html> Bifrost colors follow OS / Browser setting (prefers-color-scheme) </html> <html class="bf-lightmode"> Always light mode Bifrost colors </html> <html class="bf-darkmode"> Always dark mode Bifrost colors </html>
Example of a color mode picker as a dropdown in the Nav top bar implemented in react.

Display element only in light or dark mode

Apply one of the following class names to make an element only visible in either light or dark mode:

  • .bf-light-only is visible when:
    • Forced light mode <html class="bf-lightmode"> or
    • prefers-color-scheme is "light" and <html> has no color mode class
  • .bf-dark-only is visible for:
    • Forced dark mode <html class="bf-darkmode"> or
    • prefers-color-scheme is "dark" and <html> has no color mode class
<div class="bf-light-only"> HTML tag has "bf-lightmode" class, or `prefers-color-scheme` is "light" </div> <div class="bf-dark-only"> HTML tag has "bf-darkmode" class, or `prefers-color-scheme` is "dark" </div>
<div class="bf-light-only"> HTML tag has "bf-lightmode" class, or `prefers-color-scheme` is "light" </div> <div class="bf-dark-only"> HTML tag has "bf-darkmode" class, or `prefers-color-scheme` is "dark" </div>
HTML tag has "bf-lightmode" class, or `prefers-color-scheme` is "light"
HTML tag has "bf-darkmode" class, or `prefers-color-scheme` is "dark"

Apply css only in light or dark mode

Partial browser support

Use a style query in CSS to check if --bf-mode is light or dark:

<style> .testElement:after { content: " Unknown :("; /* firefox? other old browser? */ } @container style(--bf-mode: light) { .testElement:after { content: " Light mode!"; } } @container style(--bf-mode: dark) { .testElement:after { content: " Dark mode!"; } } </style> <div class="testElement">Current mode is:</div>
<style> .testElement:after { content: " Unknown :("; /* firefox? other old browser? */ } @container style(--bf-mode: light) { .testElement:after { content: " Light mode!"; } } @container style(--bf-mode: dark) { .testElement:after { content: " Dark mode!"; } } </style> <div class="testElement">Current mode is:</div>
Current mode is: