Design Tokens

An agnostic way to store variables such as typography, color, and spacing.


The Royal Navy Design Tokens are available as an NPM package.

// npm
npm install @royalnavy/design-tokens

// yarn
yarn add @royalnavy/design-tokens


The reccomended way to access tokens is using the supplied selector functions.

Simply import the selector object and then destructure the selectors you want to use out of this.

import { selectors } from "@royalnavy/design-tokens";

const { color, spacing, mediaQuery } = selectors

// inside a styled-component
const StyledExample = styled.div`
  color: ${color('action', '500')};
  margin-top: ${spacing('2')};

  ${mediaQuery({ gte: 'xs', lt: 'xl', media: '' })`
    // @media and (min-width:576px) and (max-width:1400px)
    color: black;
SelectorAliasExample Return ValueDescription
animation0.2sAnimation timing values.
breakpoint{ breakpoint: '768px', baseFontSize: '96%' }Raw object containing breakpoint and associated baseFontSize.
mediaQuerymqSee usage example above.Tagged template literal that generates a media query string.
color#FFFFFFA color value as a hex string.
shadow0 1px 3px rgba(0, 0, 0, 0.04)Preset box-shadow values.
spacing0.5remFixed spacing value in REMs.
fontSize0.5remFixed font-size value in REMs.
zIndex6001Scoped z-index value with optional modifier.

The selectors are typed. We reccomend using the hinting in your IDE to see the signatures and available arguments for each selector. Alternatively, you can see the raw tokens here on GitHub.

Raw Tokens

It's also possible to access the raw underlying tokens.

We consider these to be implementation detail (they may change without notice), as such we recommend using selectors over raw tokens in most instances.


import { ColorNeutral100 } from '@royalnavy/design-tokens'


@use '@royalnavy/design-tokens' as $vars