Skip to documentation
Design system / Sources & standards
Current repository source
ADR-0111-browser-color-mode-and-tenant-composition.md
docs/decisions/ADR-0111-browser-color-mode-and-tenant-composition.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-0111: Browser color mode and tenant composition ## Status accepted ## Date 2026-10-29 ## Context CXH-329 requires accessible light/dark selection for every logged-in role, including sidebar and non-sidebar views. Existing dark semantic tokens are unused by the application. Tenant inline tokens describe light palettes and would mask a root dark class. ## Options considered 1. Toggle only the root class. Tenant consoles would remain light. 2. Persist mode on the server or replace tenant selections. This couples a browser preference to branding and permissions. 3. Compose browser mode with server-resolved branding using the existing theme library and semantic tokens (chosen). ## Decision - Use the installed `next-themes` provider below the root body. Keep `.dark` as the theme strategy. Default to light; offer only light and dark. Do not follow the operating-system preference. - Persist the browser-wide, non-sensitive choice in localStorage under `cxh-color-mode`. The library applies the saved root class before hydration and synchronizes tabs. If storage is unavailable, switching remains session-local; reload persistence cannot be guaranteed. - Keep routes as server-rendered authorization and initial-data boundaries. Mode is ambient presentation Context, not server data or a new client store. - Every authenticated AuthButton exposes an account menu, including unnamed users. Include an Appearance radio group and preserve the supplied Sign out destination. Radix owns keyboard selection, Escape and focus restoration. Keep topbar and sidebar menu portals within their theme/modal owner. - Keep tenant selection and custom-palette storage unchanged. `getColorModeThemeStyle` composes their light semantic contract with CSS `light-dark()`. Root aliases resolve the existing dark semantic tokens outside the tenant scope. CSS owns `color-scheme` at the same root class boundary. - Preserve exact light values. In dark mode, retain primary hue, use OKLCH lightness 0.75 and cap chroma at 0.15 for readable actions, links and focus. Pair primary with neutral-950. Sidebar primary and selected navigation use the same pair. Other dark roles reuse the existing base dark semantics. These are mode adaptations, not a new selectable palette catalog. - Public documentation uses the real components and composition helper with fictional data. Its bounded preview Context requests `forcedTheme` from the root provider, the sole root-class owner. It does not persist product preferences. Releasing the override restores the provider's current saved mode. Full-width shell specimens use the application provider and disclose that their mode choice persists. ## Supersession scope Extends ADR-0030/0032/0036. Supersedes only ADR-0038's exact-primary and fixed light secondary/accent derivation for **dark rendering**; light derivation, saved colors, validation and authorization remain unchanged. Extends ADR-0107's account presentation to all authenticated shells and adds a browser color preference; its navigation, placement, disclosure and authorization rules remain accepted. No saved sidebar preference is added. ## Rationale A browser preference needs no new backend or role permission. Reusing the installed provider and semantic dark roles avoids a second theme store. Root-scoped aliases prevent tenant light overrides from hiding dark mode. Hue-preserving primary adaptation retains branding without expanding CXH-273 palette exploration. ## Consequences - Verify both modes, all preset/custom compositions, keyboard access, responsive shells, reload persistence and Sign out. - Modern browsers must support CSS `light-dark()` and relative OKLCH colors. - Branding storage, permission checks, navigation destinations, audit operations and deployment policy remain unchanged. No database migration or AWS resource is needed.All sources and standards