How to use
There are two different ways to apply a color to a UI element, via design tokens or via CSS helper classes.
Which one to use depends on the context since both refer to the same design token values. From the design system perspective there’s no difference between the two methods (it’s more of a preference for the “consumer” codebase).
Design tokens
You can use the color design tokens directly in your CSS definitions:
.your-selector {
color: var(--token-color-foreground-primary);
background: var(--token-color-surface-faint);
border: (--token-color-border-strong);
& :hover {
color: var(--token-color-foreground-high-contrast);
background: var(--token-color-foreground-action-active);
}
}
CSS helper classes
You can use one of the predefined “color” CSS helper classes:
<div class="hds-foreground-primary hds-surface-faint hds-border-strong">...</div>
To use this classes you have to import the CSS file [products|devdot]/css/helpers/colors.css
from the @hashicorp/design-system-tokens
package.
Semantic Tokens
Foreground
Use for text and icons.
foreground-strong
- CSS Variable
- CSS Helper
- HEX
foreground-primary
- CSS Variable
- CSS Helper
- HEX
foreground-faint
- CSS Variable
- CSS Helper
- HEX
foreground-high-contrast
- CSS Variable
- CSS Helper
- HEX
foreground-disabled
- CSS Variable
- CSS Helper
- HEX
foreground-action
- CSS Variable
- CSS Helper
- HEX
foreground-action-hover
- CSS Variable
- CSS Helper
- HEX
foreground-action-active
- CSS Variable
- CSS Helper
- HEX
foreground-highlight
- CSS Variable
- CSS Helper
- HEX
foreground-highlight-on-surface
- CSS Variable
- CSS Helper
- HEX
foreground-highlight-high-contrast
- CSS Variable
- CSS Helper
- HEX
foreground-success
- CSS Variable
- CSS Helper
- HEX
foreground-success-on-surface
- CSS Variable
- CSS Helper
- HEX
foreground-success-high-contrast
- CSS Variable
- CSS Helper
- HEX
foreground-warning
- CSS Variable
- CSS Helper
- HEX
foreground-warning-on-surface
- CSS Variable
- CSS Helper
- HEX
foreground-warning-high-contrast
- CSS Variable
- CSS Helper
- HEX
foreground-critical
- CSS Variable
- CSS Helper
- HEX
foreground-critical-on-surface
- CSS Variable
- CSS Helper
- HEX
foreground-critical-high-contrast
- CSS Variable
- CSS Helper
- HEX
Surface
Use for container and component backgrounds.
surface-primary
- CSS Variable
- CSS Helper
- HEX
surface-faint
- CSS Variable
- CSS Helper
- HEX
surface-strong
- CSS Variable
- CSS Helper
- HEX
surface-interactive
- CSS Variable
- CSS Helper
- HEX
surface-interactive-hover
- CSS Variable
- CSS Helper
- HEX
surface-interactive-active
- CSS Variable
- CSS Helper
- HEX
surface-interactive-disabled
- CSS Variable
- CSS Helper
- HEX
surface-action
- CSS Variable
- CSS Helper
- HEX
surface-highlight
- CSS Variable
- CSS Helper
- HEX
surface-success
- CSS Variable
- CSS Helper
- HEX
surface-warning
- CSS Variable
- CSS Helper
- HEX
surface-critical
- CSS Variable
- CSS Helper
- HEX
Border
Use for container and component borders. Neutral values can also be used for horizontal rules.
border-primary
- CSS Variable
- CSS Helper
- HEX
border-faint
- CSS Variable
- CSS Helper
- HEX
border-strong
- CSS Variable
- CSS Helper
- HEX
border-action
- CSS Variable
- CSS Helper
- HEX
border-highlight
- CSS Variable
- CSS Helper
- HEX
border-success
- CSS Variable
- CSS Helper
- HEX
border-warning
- CSS Variable
- CSS Helper
- HEX
border-critical
- CSS Variable
- CSS Helper
- HEX
Focus
Use to indicate an element is in a focused state. Critical values for critical actions only, Action values for everything else. Notice: they're used internally by the design system to define focus states.
focus-action
- CSS Variable
- CSS Helper
- HEX
focus-action
- CSS Variable
- CSS Helper
- HEX
focus-critical
- CSS Variable
- CSS Helper
- HEX
focus-critical
- CSS Variable
- CSS Helper
- HEX
Page
Use for page backgrounds.
page-primary
- CSS Variable
- CSS Helper
- HEX
page-faint
- CSS Variable
- CSS Helper
- HEX
Branding Colors
Hashicorp
hashicorp-brand
- CSS Variable
- CSS Helper
- HEX
Boundary
boundary-brand
- CSS Variable
- CSS Helper
- HEX
boundary-foreground
- CSS Variable
- CSS Helper
- HEX
boundary-surface
- CSS Variable
- CSS Helper
- HEX
boundary-border
- CSS Variable
- CSS Helper
- HEX
boundary-gradient
- CSS Variable
- CSS Helper
- HEX
boundary-gradient
- CSS Variable
- CSS Helper
- HEX
boundary-gradient
- CSS Variable
- CSS Helper
- HEX
boundary-gradient
- CSS Variable
- CSS Helper
- HEX
Consul
consul-brand
- CSS Variable
- CSS Helper
- HEX
consul-foreground
- CSS Variable
- CSS Helper
- HEX
consul-surface
- CSS Variable
- CSS Helper
- HEX
consul-border
- CSS Variable
- CSS Helper
- HEX
consul-gradient
- CSS Variable
- CSS Helper
- HEX
consul-gradient
- CSS Variable
- CSS Helper
- HEX
consul-gradient
- CSS Variable
- CSS Helper
- HEX
consul-gradient
- CSS Variable
- CSS Helper
- HEX
Hcp
hcp-brand
- CSS Variable
- CSS Helper
- HEX
Nomad
nomad-brand
- CSS Variable
- CSS Helper
- HEX
nomad-foreground
- CSS Variable
- CSS Helper
- HEX
nomad-surface
- CSS Variable
- CSS Helper
- HEX
nomad-border
- CSS Variable
- CSS Helper
- HEX
nomad-gradient
- CSS Variable
- CSS Helper
- HEX
nomad-gradient
- CSS Variable
- CSS Helper
- HEX
nomad-gradient
- CSS Variable
- CSS Helper
- HEX
nomad-gradient
- CSS Variable
- CSS Helper
- HEX
Packer
packer-brand
- CSS Variable
- CSS Helper
- HEX
packer-foreground
- CSS Variable
- CSS Helper
- HEX
packer-surface
- CSS Variable
- CSS Helper
- HEX
packer-border
- CSS Variable
- CSS Helper
- HEX
packer-gradient
- CSS Variable
- CSS Helper
- HEX
packer-gradient
- CSS Variable
- CSS Helper
- HEX
packer-gradient
- CSS Variable
- CSS Helper
- HEX
packer-gradient
- CSS Variable
- CSS Helper
- HEX
Terraform
terraform-brand
- CSS Variable
- CSS Helper
- HEX
terraform-foreground
- CSS Variable
- CSS Helper
- HEX
terraform-surface
- CSS Variable
- CSS Helper
- HEX
terraform-border
- CSS Variable
- CSS Helper
- HEX
terraform-gradient
- CSS Variable
- CSS Helper
- HEX
terraform-gradient
- CSS Variable
- CSS Helper
- HEX
terraform-gradient
- CSS Variable
- CSS Helper
- HEX
terraform-gradient
- CSS Variable
- CSS Helper
- HEX
Vagrant
vagrant-brand
- CSS Variable
- CSS Helper
- HEX
vagrant-foreground
- CSS Variable
- CSS Helper
- HEX
vagrant-surface
- CSS Variable
- CSS Helper
- HEX
vagrant-border
- CSS Variable
- CSS Helper
- HEX
vagrant-gradient
- CSS Variable
- CSS Helper
- HEX
vagrant-gradient
- CSS Variable
- CSS Helper
- HEX
vagrant-gradient
- CSS Variable
- CSS Helper
- HEX
vagrant-gradient
- CSS Variable
- CSS Helper
- HEX
Vault
vault-brand
- CSS Variable
- CSS Helper
- HEX
vault-brand-alt
- CSS Variable
- CSS Helper
- HEX
vault-foreground
- CSS Variable
- CSS Helper
- HEX
vault-surface
- CSS Variable
- CSS Helper
- HEX
vault-border
- CSS Variable
- CSS Helper
- HEX
vault-gradient
- CSS Variable
- CSS Helper
- HEX
vault-gradient
- CSS Variable
- CSS Helper
- HEX
vault-gradient
- CSS Variable
- CSS Helper
- HEX
vault-gradient
- CSS Variable
- CSS Helper
- HEX
Waypoint
waypoint-brand
- CSS Variable
- CSS Helper
- HEX
waypoint-foreground
- CSS Variable
- CSS Helper
- HEX
waypoint-surface
- CSS Variable
- CSS Helper
- HEX
waypoint-border
- CSS Variable
- CSS Helper
- HEX
waypoint-gradient
- CSS Variable
- CSS Helper
- HEX
waypoint-gradient
- CSS Variable
- CSS Helper
- HEX
waypoint-gradient
- CSS Variable
- CSS Helper
- HEX
waypoint-gradient
- CSS Variable
- CSS Helper
- HEX
Core Palette
Core Palette colors should be used sparingly and only when the correct semantic mapping isn’t available for the use case.
Blue
blue-500
- CSS Variable
- CSS Helper
- HEX
blue-400
- CSS Variable
- CSS Helper
- HEX
blue-300
- CSS Variable
- CSS Helper
- HEX
blue-200
- CSS Variable
- CSS Helper
- HEX
blue-100
- CSS Variable
- CSS Helper
- HEX
blue-50
- CSS Variable
- CSS Helper
- HEX
Purple
purple-500
- CSS Variable
- CSS Helper
- HEX
purple-400
- CSS Variable
- CSS Helper
- HEX
purple-300
- CSS Variable
- CSS Helper
- HEX
purple-200
- CSS Variable
- CSS Helper
- HEX
purple-100
- CSS Variable
- CSS Helper
- HEX
purple-50
- CSS Variable
- CSS Helper
- HEX
Green
green-500
- CSS Variable
- CSS Helper
- HEX
green-400
- CSS Variable
- CSS Helper
- HEX
green-300
- CSS Variable
- CSS Helper
- HEX
green-200
- CSS Variable
- CSS Helper
- HEX
green-100
- CSS Variable
- CSS Helper
- HEX
green-50
- CSS Variable
- CSS Helper
- HEX
Amber
amber-500
- CSS Variable
- CSS Helper
- HEX
amber-400
- CSS Variable
- CSS Helper
- HEX
amber-300
- CSS Variable
- CSS Helper
- HEX
amber-200
- CSS Variable
- CSS Helper
- HEX
amber-100
- CSS Variable
- CSS Helper
- HEX
amber-50
- CSS Variable
- CSS Helper
- HEX
Red
red-500
- CSS Variable
- CSS Helper
- HEX
red-400
- CSS Variable
- CSS Helper
- HEX
red-300
- CSS Variable
- CSS Helper
- HEX
red-200
- CSS Variable
- CSS Helper
- HEX
red-100
- CSS Variable
- CSS Helper
- HEX
red-50
- CSS Variable
- CSS Helper
- HEX
Neutral
neutral-700
- CSS Variable
- CSS Helper
- HEX
neutral-600
- CSS Variable
- CSS Helper
- HEX
neutral-500
- CSS Variable
- CSS Helper
- HEX
neutral-400
- CSS Variable
- CSS Helper
- HEX
neutral-300
- CSS Variable
- CSS Helper
- HEX
neutral-200
- CSS Variable
- CSS Helper
- HEX
neutral-100
- CSS Variable
- CSS Helper
- HEX
neutral-50
- CSS Variable
- CSS Helper
- HEX
neutral-0
- CSS Variable
- CSS Helper
- HEX
Alpha
alpha-300
- CSS Variable
- CSS Helper
- HEX
alpha-200
- CSS Variable
- CSS Helper
- HEX
alpha-100
- CSS Variable
- CSS Helper
- HEX