Skip to main content

Customising tokens

Every value in the theme comes from the Arabesque design system's tokens: CSS custom properties named --al-*, the same names the design system's own CSS uses. The theme carries a copy of them (src/css/tokens.css), taken from a release of the design system.

Use the tokens​

Refer to tokens by name in src/css/custom.css, CSS modules and inline styles. They switch with the colour mode, and with Arabic, on their own.

src/css/custom.css
.release-note {
padding: var(--al-space-4) var(--al-space-5);
border: var(--al-border-hairline) solid var(--al-color-line);
border-radius: var(--al-radius-sm);
font-family: var(--al-font-serif);
color: var(--al-color-text-muted);
}

Override a token for one site​

Redefine the token in src/css/custom.css. Set light values on :root and dark values on :root[data-theme='dark'], the attribute Docusaurus sets on <html>.

src/css/custom.css
:root {
--al-size-measure: 70ch;
}
:root[data-theme='dark'] {
--al-color-bg: oklch(16% 0.017 265);
}
warning

Check contrast when you change a colour. Text must hold 4.5:1 on the grounds it's used on, in both themes; control borders, icons and the focus ring must hold 3:1.

Update to a new release of the design system​

The theme records the release it's built on in package.json (arabesque.designSystem). To move to a new one, check the release out beside the theme and copy it in:

git clone --depth 1 --branch v0.9.0 https://github.com/ArabesqueLabs/design-system.git ../design-system
npm run sync-design-system -- ../design-system

The script copies the design system's built tokens, font files and licences, logos and icon set into the theme, and records the version. Then check the site, and the design system's changelog for renamed tokens. Don't edit the copied files by hand.

The tokens​

Colour​

TokenUse
--al-color-bgThe page ground.
--al-color-surface, --al-color-surface-sunkPanels and cards; the sidebar, code and pressed grounds.
--al-color-textText and the mark.
--al-color-text-mutedLedes, hints and metadata.
--al-color-lineHairlines.
--al-color-line-strong, --al-color-controlEdges a reader must see; control borders.
--al-color-accent, --al-color-accent-hover, --al-color-on-accentThe teal accent: primary buttons, link underlines, the current page, focus.
--al-color-accent-washSelected and marked grounds, such as a marked code line.
--al-color-info, -success, -warning, -danger, and their -wash groundsNotices, always with an icon and a word.
--al-color-syntax-*Code colours.
--al-color-pattern-*The pattern.
--al-color-backdropBehind the mobile menu and dialogs.

Type​

TokenValue
--al-font-sansJost, then IBM Plex Sans Arabic: interface and documents.
--al-font-displayJost, then Kufam: headings.
--al-font-serifNewsreader, then Amiri: ledes and prose.
--al-font-monoIBM Plex Mono: code.
--al-text-xs … --al-text-3xl, --al-text-displayThe type scale. Arabic runs 8% larger.
--al-leading-*, --al-tracking-*Line heights and letter spacing; Arabic has its own.

Space, shape and motion​

TokenValues
--al-space-1 … --al-space-164px to 64px; --al-space-section and --al-space-gutter are fluid.
--al-radius-sm, --al-radius-md, --al-radius-full2px (buttons, fields, notices), 4px (overlays), round.
--al-size-page, --al-size-measurePage width (1200px) and line length (65ch).
--al-size-control-md, --al-size-target-touchButtons and fields (40px), touch targets (44px).
--al-duration-fast, --al-duration-base, --al-ease-standard150ms, 250ms, and the one easing curve.

There are no shadow tokens: borders and surface steps carry depth.

How the theme maps onto Infima​

The classic theme is built on Infima. The theme sets Infima's variables from the tokens, so classic components and your own Infima classes follow the design system:

--ifm-color-primary: var(--al-color-accent);
--ifm-background-color: var(--al-color-bg);
--ifm-font-color-base: var(--al-color-text);
--ifm-font-family-base: var(--al-font-sans);
--ifm-global-radius: var(--al-radius-sm);

Change the design system's token rather than the Infima variable, so every place that uses it stays consistent.