Skip to content
Storybook

Theming

Tokens come straight from the Figma variable collections. Change a brand color or a mode and every component follows.

Token collections

The Figma file has seven variable collections. Each becomes a block in pixels-tokens.css:

CollectionModesTokensPurpose
PrimitivesDefault303Raw palette, sizes, radius, blur and type values
BrandPixels, Mono11The brand ramp (points at Blue by default)
ColorLight, Dark, Light · Mono, Dark · Mono139Semantic colors for content, background, border and surface
DimensionDesktop, Tablet, Mobile127Responsive type, spacing, radius and layout
Localeen · LTR, ar · RTL53Direction, font family and line heights for LTR / RTL
DensityDefault, Compact, Comfortable10Control heights, padding and gaps
ComponentDefault299Per-component tokens like --px-button-radius

Naming

Tokens use the Figma name with slashes turned into dashes and a --px- prefix. Semantic tokens point to primitives, and component tokens point to semantic tokens:

CSS
--px-color-blue-500: #2563eb;                                    /* Primitive */
--px-color-brand-500: var(--px-color-blue-500);                   /* Brand */
--px-color-background-brand-default: var(--px-color-brand-500);   /* Semantic */
--px-button-primary-background-default: var(--px-color-background-brand-default); /* Component */

Change the brand color

Override the Brand collection. Every button, link, focus ring and selected state updates.

CSS
:root {
  --px-color-brand-50:  #fdf2f8;
  --px-color-brand-100: #fce7f3;
  --px-color-brand-200: #fbcfe8;
  --px-color-brand-500: #db2777;
  --px-color-brand-600: #be185d;
  --px-color-brand-700: #9d174d;
}
Badge Link

Dark mode

Set data-px-theme="dark" on <html>. The Color collection switches to its Dark mode values. Try the theme button in the header.

HTML
<html data-px-theme="dark">

Right-to-left and Arabic

Set dir="rtl" (and lang="ar"). The Locale collection switches font family and line heights, and every component mirrors using logical properties. Each preview on this site has an RTL switch.

HTML
<html dir="rtl" lang="ar">

Density

Three densities from the Density collection change control heights and padding.

HTML
<html data-px-density="compact">   <!-- 32px controls -->
<html data-px-density="comfortable"> <!-- 44px controls -->
compact
default
comfortable

Responsive tokens

The Dimension collection has Desktop, Tablet and Mobile modes. They apply automatically below 1024px and 600px, so headings, spacing and layout margins shrink on small screens.