Skip to Content
StylingDesign Tokens

Design Tokens

Axiom uses CSS variables to declare design tokens and also conveniently exports the variable names in the theme object.

Declaring tokens

CSS variables

All tokens are available as CSS variables under the --ax-* prefix.

So given a tokens object like this:

{ "colors": { "bg.accent": "#2e66f7", "fg.success": "#03a65d" }, "zIndex": { "popover": "3000" } }

The following css custom properties will be available:

:root { --ax-colors-bg-accent: #2e66f7; --ax-colors-fg-success: #03a65d; --ax-zIndex-popover: 3000; }

And they can be accessed via the theme object:

import { theme } from "@optiaxiom/react"; console.log(theme.colors["bg.accent"] === "var(--ax-colors-bg-accent)"); // true console.log(theme.colors["fg.success"] === "var(--ax-colors-fg-success)"); // true console.log(theme.zIndex.popover === "var(--ax-zIndex-popover)"); // true

Consuming tokens

Using style props

For all react components you can use the various style props to set the styles using tokens.

Using component props
import { Box } from "@optiaxiom/react"; export function App() { return ( <Box bg="bg.success.subtle" color="fg.success.strong" p="16"> Using component props </Box> ); }

Consuming variables from CSS

You can also directly use the CSS variable name in your .css files.

Using CSS variables
import styles from "./App.module.css"; export function App() { return <div className={styles.root}>Using CSS variables</div>; }

Consuming variables from JS

Axiom exports a theme contract that contains a map of all tokens to the corresponding CSS custom property name.

You can use this theme object when implementing any CSS-in-JS solutions.

Using inline styles
import { theme } from "@optiaxiom/react"; export function App() { return ( <div style={{ background: theme.colors["bg.success.subtle"], color: theme.colors["fg.success.strong"], padding: "16px", }} > Using inline styles </div> ); }

Reference

borderRadius

Name

Styles

xs
var(--ax-borderRadius-xs)
sm
var(--ax-borderRadius-sm)
md
var(--ax-borderRadius-md)
lg
var(--ax-borderRadius-lg)
full
var(--ax-borderRadius-full)

boxShadow

Name

Styles

sm
var(--ax-boxShadow-sm)
md
var(--ax-boxShadow-md)
lg
var(--ax-boxShadow-lg)

colors

Name

Styles

bg.accent
var(--ax-colors-bg-accent)
bg.accent.hovered
var(--ax-colors-bg-accent-hovered)
bg.accent.light
var(--ax-colors-bg-accent-light)
bg.accent.pressed
var(--ax-colors-bg-accent-pressed)
bg.accent.subtle
var(--ax-colors-bg-accent-subtle)
bg.avatar.neutral
var(--ax-colors-bg-avatar-neutral)
bg.avatar.purple
var(--ax-colors-bg-avatar-purple)
bg.default
var(--ax-colors-bg-default)
bg.default.hovered
var(--ax-colors-bg-default-hovered)
bg.default.inverse
var(--ax-colors-bg-default-inverse)
bg.default.inverse.hovered
var(--ax-colors-bg-default-inverse-hovered)
bg.default.inverse.pressed
var(--ax-colors-bg-default-inverse-pressed)
bg.default.pressed
var(--ax-colors-bg-default-pressed)
bg.error
var(--ax-colors-bg-error)
bg.error.hovered
var(--ax-colors-bg-error-hovered)
bg.error.light
var(--ax-colors-bg-error-light)
bg.error.pressed
var(--ax-colors-bg-error-pressed)
bg.error.subtle
var(--ax-colors-bg-error-subtle)
bg.error.subtlest
var(--ax-colors-bg-error-subtlest)
bg.information
var(--ax-colors-bg-information)
bg.information.light
var(--ax-colors-bg-information-light)
bg.information.subtle
var(--ax-colors-bg-information-subtle)
bg.overlay
var(--ax-colors-bg-overlay)
bg.page
var(--ax-colors-bg-page)
bg.secondary
var(--ax-colors-bg-secondary)
bg.secondary.hovered
var(--ax-colors-bg-secondary-hovered)
bg.spinner.default
var(--ax-colors-bg-spinner-default)
bg.spinner.inverse
var(--ax-colors-bg-spinner-inverse)
bg.success
var(--ax-colors-bg-success)
bg.success.hovered
var(--ax-colors-bg-success-hovered)
bg.success.light
var(--ax-colors-bg-success-light)
bg.success.subtle
var(--ax-colors-bg-success-subtle)
bg.tertiary
var(--ax-colors-bg-tertiary)
bg.tertiary.hovered
var(--ax-colors-bg-tertiary-hovered)
bg.warning
var(--ax-colors-bg-warning)
bg.warning.hovered
var(--ax-colors-bg-warning-hovered)
bg.warning.light
var(--ax-colors-bg-warning-light)
bg.warning.subtle
var(--ax-colors-bg-warning-subtle)
border.accent
var(--ax-colors-border-accent)
border.control
var(--ax-colors-border-control)
border.control.hovered
var(--ax-colors-border-control-hovered)
border.default
var(--ax-colors-border-default)
border.disabled
var(--ax-colors-border-disabled)
border.error
var(--ax-colors-border-error)
border.focus
var(--ax-colors-border-focus)
border.focus.error
var(--ax-colors-border-focus-error)
border.secondary
var(--ax-colors-border-secondary)
border.success
var(--ax-colors-border-success)
border.tertiary
var(--ax-colors-border-tertiary)
border.warning
var(--ax-colors-border-warning)
fg.accent
var(--ax-colors-fg-accent)
fg.accent.hovered
var(--ax-colors-fg-accent-hovered)
fg.accent.strong
var(--ax-colors-fg-accent-strong)
fg.avatar.neutral
var(--ax-colors-fg-avatar-neutral)
fg.avatar.purple
var(--ax-colors-fg-avatar-purple)
fg.default
var(--ax-colors-fg-default)
fg.default.inverse
var(--ax-colors-fg-default-inverse)
fg.disabled
var(--ax-colors-fg-disabled)
fg.error
var(--ax-colors-fg-error)
fg.error.hovered
var(--ax-colors-fg-error-hovered)
fg.error.light
var(--ax-colors-fg-error-light)
fg.error.strong
var(--ax-colors-fg-error-strong)
fg.information
var(--ax-colors-fg-information)
fg.information.light
var(--ax-colors-fg-information-light)
fg.information.strong
var(--ax-colors-fg-information-strong)
fg.link.default
var(--ax-colors-fg-link-default)
fg.link.default.hovered
var(--ax-colors-fg-link-default-hovered)
fg.link.inverse
var(--ax-colors-fg-link-inverse)
fg.link.subtle
var(--ax-colors-fg-link-subtle)
fg.link.visited
var(--ax-colors-fg-link-visited)
fg.secondary
var(--ax-colors-fg-secondary)
fg.spinner.default
var(--ax-colors-fg-spinner-default)
fg.spinner.inverse
var(--ax-colors-fg-spinner-inverse)
fg.success
var(--ax-colors-fg-success)
fg.success.hovered
var(--ax-colors-fg-success-hovered)
fg.success.light
var(--ax-colors-fg-success-light)
fg.success.strong
var(--ax-colors-fg-success-strong)
fg.tertiary
var(--ax-colors-fg-tertiary)
fg.warning
var(--ax-colors-fg-warning)
fg.warning.hovered
var(--ax-colors-fg-warning-hovered)
fg.warning.inverse
var(--ax-colors-fg-warning-inverse)
fg.warning.light
var(--ax-colors-fg-warning-light)
fg.warning.strong
var(--ax-colors-fg-warning-strong)
fg.white
var(--ax-colors-fg-white)

duration

Name

Styles

sm
var(--ax-duration-sm)
md
var(--ax-duration-md)
lg
var(--ax-duration-lg)

fontFamily

Name

Styles

mono
var(--ax-fontFamily-mono)
sans
var(--ax-fontFamily-sans)

fontSize

Name

Styles

xs
fontSize: var(--ax-fontSize-xs-fontSize);lineHeight: var(--ax-fontSize-xs-lineHeight);
sm
fontSize: var(--ax-fontSize-sm-fontSize);lineHeight: var(--ax-fontSize-sm-lineHeight);
md
fontSize: var(--ax-fontSize-md-fontSize);lineHeight: var(--ax-fontSize-md-lineHeight);
lg
fontSize: var(--ax-fontSize-lg-fontSize);lineHeight: var(--ax-fontSize-lg-lineHeight);
xl
fontSize: var(--ax-fontSize-xl-fontSize);lineHeight: var(--ax-fontSize-xl-lineHeight);
2xl
fontSize: var(--ax-fontSize-2xl-fontSize);lineHeight: var(--ax-fontSize-2xl-lineHeight);
3xl
fontSize: var(--ax-fontSize-3xl-fontSize);lineHeight: var(--ax-fontSize-3xl-lineHeight);
4xl
fontSize: var(--ax-fontSize-4xl-fontSize);lineHeight: var(--ax-fontSize-4xl-lineHeight);

maxSize

Name

Styles

xs
var(--ax-maxSize-xs)
sm
var(--ax-maxSize-sm)
md
var(--ax-maxSize-md)
lg
var(--ax-maxSize-lg)

size

Name

Styles

2xs
var(--ax-size-2xs)
xs
var(--ax-size-xs)
sm
var(--ax-size-sm)
md
var(--ax-size-md)
lg
var(--ax-size-lg)
xl
var(--ax-size-xl)
3xl
var(--ax-size-3xl)

zIndex

Name

Styles

popover
var(--ax-zIndex-popover)
toast
var(--ax-zIndex-toast)
tooltip
var(--ax-zIndex-tooltip)
Last updated on