Skip to main content

Global themes are used to provide light and dark display modes at the application level.

For applying a localized background color theme to a single container, see contextual theming.

Global theme utility classes MUST be be applied on the parent <html> element (on the same element as the bolt-typography class).

Options include:

  • Light: (Default)
    • Applies default light mode appearance and theme token values
    • The SASS versions of theme tokens will always reflect their default, light mode values
  • Dark: use bolt-theme--dark class
    • Updates Bolt styles & CSS theme token values to their dark mode equivalents
  • System: use bolt-theme--system class
    • Follows user's system preferences to apply either light or dark mode
Example: applying dark mode
<html class="bolt-typography bolt-theme--dark">
  ...
</html>

To see different theme configurations in action: Open display settings

Do

  • Let users opt-in to dark mode.
  • Apply light and dark themes at the global level.
  • Use the same global theme across all pages and screens.
  • Use CSS tokens when building themed UI.

Don't

  • Do not force dark mode on end users.
  • Do not attempt to customize global theme definitions.
  • Do not use the SASS versions of theme tokens, unless the application will only ever need to support light mode.

Theme tokens primarily define values for color roles, in order to help build custom UI components that are compatible with global themes.

See design tokens documentation for a full list of values.

Use theme tokens when styling elements that should follow the global theme, but should not be affected by the color of a background container. For example, a tile provides its own independent surface, and thus should not be affected by local contextual theme.

Conditional display utilities allow developers to swap out content that should only be presented in light mode or dark mode.

Options include:

  • bolt-theme--light-content
    • Add this class to default light mode content to hide it in dark mode.
  • bolt-theme--dark-content
    • Add this class to content that should only be visible in dark mode.

This approach may be necessary when using static assets, such as images, that cannot make use of dynamic CSS tokens. For example, logos or brand icons may have multiple versions intended for use on light or dark backgrounds.

<bolt-tile-group>
  <bolt-tile href="#" label="Tile label">
    <img
      slot="thumbnail"
      src="/images/map-outline.svg"
      class="bolt-theme--light-content"
    />
    <img
      slot="thumbnail"
      src="/images/map-outline-white.svg"
      class="bolt-theme--dark-content"
    />
  </bolt-tile>
  ...
</bolt-tile-group>

Display settings

Note: not all settings persist across pages

Default Compact (-1) Sparse (+1) XL (default) 2XL 3XL Default Min Max Light (default) System Dark Branded (default) Unbranded