Skip to documentation

Design system / Sources & standards

Current repository source

ADR-0038-custom-palette-semantic-token-derivation.md

docs/decisions/ADR-0038-custom-palette-semantic-token-derivation.md

This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.

# ADR-0038: Custom palette semantic-token derivation

## Status

accepted

## Date

2026-07-21

## Context

ADR-0037 established one stored custom palette per tenant but deferred runtime activation. Tenant Admins now need to apply a saved custom palette without gaining arbitrary access to all semantic tokens.

## Decision

- A selected custom palette derives a scoped semantic-token layer over the stable Slate token contract.
- Primary is retained as entered and maps to primary actions, links, focus, info, primary sidebar treatment, and chart one.
- Secondary retains hue/chroma but normalizes to OKLCH lightness `0.94`; it maps to secondary, muted, and sunken surface roles.
- Accent retains hue/chroma but normalizes to OKLCH lightness `0.985`; it maps to accent, selected, and sidebar accent roles.
- Custom-palette saves persist the normalized secondary and accent hex values and return them to the editor, so controls reflect the applied palette.
- Primary foreground retains the primary hue and normalizes to OKLCH lightness `0.1` when primary is above `0.5`, or `0.9` when primary is below `0.5`. Stable feedback, destructive, and remaining chart tokens continue to use their reviewed base values.

## Consequences

- Custom palettes now visibly affect the console after selection.
- Only three tenant-provided colors are persisted; the app owns the broader semantic token contract.
- The save API enforces minimum contrast for primary actions, focus visibility, subdued surfaces, and accent text. Dark-mode derivation and gamut optimization remain future work.

## Related decisions

- Supersedes ADR-0037's deferred custom-theme activation decision.
- Extends ADR-0037's one-record-per-tenant storage boundary.
All sources and standards
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.