Skip to content

Tokens & CSS for Dataviz Colors

For design guidelines, see Color Guidelines.

We have defined a color palette for data visualization that should be used across all brands. On web, you can apply the dataviz colors using CSS variables or Utility classes.

The dataviz color names include dv for dataviz, to differentiate them from regular WARP colors.

On this page:

Alternative 1: CSS variables

For CSS variables to work, you need to include a link to the dataviz CSS file in your project:

  • https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/dataviz.css

Add this to your index.html

html
<link
  rel="stylesheet"
  href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/dataviz.css"
/>

We have defined different color shades to be used for different element types (background, border, icon, line and text). We call these color categories.

The pattern for the variable name is: var(--w-dv-s-color-[color category]-[semantic-color]

Example of CSS variables for the Primary semantic color:

Color categoryCSS variable
Backgroundvar(--w-dv-s-color-background-primary)
Background Subtlevar(--w-dv-s-color-background-primary-subtle)
Bordervar(--w-dv-s-color-border-primary)
Iconvar(--w-dv-s-color-icon-primary)
Linevar(--w-dv-s-color-line-primary)
Textvar(--w-dv-s-color-text-primary)

CSS variables can applied to both HTML and SVG elements.

HTML example

Example of applying the primary dataviz border color to a <div> border:

html
<div style="width: 24px; height: 80px; 
            border: 2px solid var(--w-dv-s-color-border-primary);">
</div>

SVG example

Example of applying the primary dataviz border color to a <rect> stroke in an SVG:

xml
<rect x="16" y="16" width="24" height="80"
  stroke="var(--w-dv-s-color-border-primary)" 
  stroke-width="2">
</rect>

Alternative 2: Utility classes

Before using the utility classes, you need to install UnoCSS, see Get started for Web developers. You need version 2.1 of UnoCSS for the dataviz colors to work.

Utility classes for HTML elements

Example of HTML utility classes for the Primary semantic color:

Color categoryClassDescription
Backgrounddv-s-bg-primarybackground-color: var(--w-dv-s-color-background-primary)
Background Subtledv-s-bg-primary-subtlebackground-color: var(--w-dv-s-color-background-primary-subtle)
Borderdv-s-border-primaryborder-color: var(--w-dv-s-color-border-primary)
Icondv-s-icon-primarycolor: var(--w-dv-s-color-icon-primary)
Linedv-s-line-primaryborder-color: var(--w-dv-s-color-line-primary)
Textdv-s-text-primarycolor: var(--w-dv-s-color-text-primary)

Example

Example of a <div> using using the primary background subtle as background-color and primary border color as border-color:

html
<div style="width: 24px; height: 80px;" 
     class="dv-s-bg-primary-subtle dv-s-border-primary">
</div>

Utility classes for SVG elements

Since SVGs have different props for applying color than HTML has, we have defined utility classes specifically for applying colors to SVG elements using fill or stroke. Read more about SVG fill and stroke.

The utility class names are different depending on what you want to style – fill or stroke.

  • Fill dv-s-fill-[element type]-[semantic-color]
  • Stroke dv-s-stroke-[element type]-[semantic-color]

Example using the primary color:

Color categoryFillStroke
Linedv-s-fill-line-primary*dv-s-stroke-line-primary
Backgrounddv-s-fill-bg-primarydv-s-stroke-bg-primary*
Background subtledv-s-fill-bg-primary-subtledv-s-stroke-bg-primary-subtle*
Borderdv-s-fill-border-primary*dv-s-stroke-border-primary
Icondv-s-fill-icon-primarydv-s-stroke-icon-primary
Textdv-s-fill-text-primary*dv-s-stroke-text-primary*

* Yes, it is a bit strange that it is possible to apply a Background color as stroke, or Line color as fill. But it is technically possible, and might be useful in some situations.

Example

Example of an SVG <rect> using the primary background subtle color as fill and primary border color as stroke:

xml
<rect x="16" y="16" width="24" height="80"
  class="dv-s-fill-bg-primary-subtle dv-s-stroke-border-primary"
  stroke-width="2">
</rect>

Hack to apply HTML classes to SVG elements

The regular WARP utility classes don't work for applying SVG fill or stroke. But you can do something like this to:

xml
<text className="s-text" fill="currentColor">
  <!-- Your text goes here -->
</text>

Hover, focus and active

All dataviz colors tokens (except the chart colors) have a corresponding highlight token to be used on hover, tap and keyboard focus. Add -highlight to the end of the variable name or class name to get the highlight color.

Example: CSS variable

CSS variable example, primary background color:

Default colorHighlight color
var(--w-dv-s-color-background-primary)var(--w-dv-s-color-background-primary-highlight)

Example: Utility class

Utility class example, primary background color:

TypeDefault colorHighlight color
HTML backgrounddv-s-bg-primarydv-s-bg-primary-highlight
SVG filldv-s-fill-bg-primarydv-s-fill-bg-primary-highlight
SVG strokedv-s-stroke-bg-primarydv-s-stroke-bg-primary-highlight

See Interaction for more information and examples.

iOS

The pattern for the variable name is:

  • Warp.DatavizToken.[colorCategory][SemanticColor] for SwiftUI Color
  • Warp.DatavizUIToken.[colorCategory][SemanticColor] for UIKit UIColor

Examples:

  • Warp.DatavizToken.backgroundPrimary / Warp.DatavizUIToken.backgroundPrimary
  • Warp.DatavizToken.borderCategory1 / Warp.DatavizUIToken.borderCategory1
  • Warp.DatavizToken.lineSecondary / Warp.DatavizUIToken.lineSecondary
  • Warp.DatavizToken.lineSecondaryHighlight / Warp.DatavizUIToken.lineSecondaryHighlight

Android

TBD