Pit Viper

v1.90.0

Pit Viper

v1.90.0
v1 / v2

Theming

Pit Viper allows you to override some of its default values to support brands other than Turquoise Health.

Under the hood, Pit Viper uses the CSS var() function to set themeable values to a custom property, and if that property doesn’t exist, it will default to the Pit Viper token value.

.pv-surface-brand {
background-color: var(--color-background-brand, #{$color-background-brand});
}

Creating a theme

To create theme, include your values in a CSS file via a link tag in the document’s head to point to an external file, or use a style tag to add them directly to a page.

Your custom properties can be scoped to the :root (the entire document), or you can isolate them to a specific area of the page by scoping it to a class.

The examples below are editable. You can replace any of the color names with CSS color names or any other supported color values and this page’s theme will update in realtime. (You can also delete the text to revert back to Pit Viper’s default values.)

Scoping to the root

Use :root to make custom properties available to all elements in the document that use them. You can override as many or as few values as you want. Any .pv classes will use their default values unless specifically overridden here.

Note: to avoid repetition, you can use your own custom properties to set a value in one place and have it apply to several different contexts.

Scoping to a class

You can scope your styles to a class and all elements within a container with that class will have the theme values applied. It will still inherit default styles from Pit Viper or any custom properties declared in :root unless explicitly overridden in the class scope.

In the following example, --color-background-brand-accent and --color-border are overriding values declared in the :root example above. The rest of the values are only overriding Pit Viper’s defaults.

Example
A container with custom properties scoped to its class.

HTML
<div class="myClass">
<div class="pv-surface-accent pv-inset-square pv-bordered">
<button type="button" class="pv-button-primary">Button</button>
</div>
</div>

Accessibility considerations

When creating themes, be sure to check the contrast between foreground and background colors to ensure they have a contrast ratio of at least 4.5:1 (WCAG AA).

List of themeable properties

Custom Property Default Value
--font-family-body 'HK G rotesk', sans-serif
--color-text-body #02363D
--color-text-interactive #176F6F
--color-text-brand #176F6F
--color-text-accent #FFFFFF
--color-text-inverse #FFFFFF
--color-text-subdued #6E7784
--color-background-body #FFFFFF
--color-background-accent #F8F8FA
--color-background-brand #02363D
--color-background-brand-accent #E2F7F5
--color-background-brand-highlight #176F6F
--color-background-interactive #A8E6E1
--color-border #DCDFE4
--color-border-accent #176F6F
--color-border-warning #EFC666
--color-border-brand #02363D
--color-border-accent #176F6F
--border-width-sm 2px
--radius-sm 2px
--button-radius 2rem
--color-button-text #FFFFFF
--color-button-text-hover #FFFFFF
--color-button-primary-background #176F6F
--color-button-primary-background-hover #0D5256
--color-button-primary-background-active #218C88
--color-button-secondary-text #FFFFFF
--color-button-secondary-text-hover #FFFFFF
--color-button-secondary-background #02363D
--color-button-secondary-background-hover #011214
--color-button-secondary-background-active #0D5256
--summary-background-image-closed*
--summary-background-image-open*
--select-background-image*
--label-font-weight 600
--highlight-background #FAECCC
--highlight-square $yellow-40 #EAB333
--highlight-category-square #351BC5

* URL-encoded SVGs