ThemeProvider
Theme context for light, dark, and high-contrast modes.
Status: beta. Group: utility. Markdown version: /design-system/components/theme-provider.md
When to use
Context provider owning the light/dark/high-contrast theme state, class application, and persistence. Mounted once by the app shell.
When not to use
The contract records no forbidden uses.
Look-alikes
The contract names no look-alike with a deciding condition.
Props
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
children | React.ReactNode | none | Subtree that receives the theme context. | Yes |
forcedTheme | "light" | "dark" | "hcb" | "hcw" | none | Pin the theme regardless of stored/system preference (e.g. external embeds). | No |
Variants
- Allowed
forcedThemevalues:light,dark,hcb,hcw.
Invalid combinations
The contract records no invalid combinations.
Keyboard
The contract records no keyboard interaction.
Rules
Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.
| Level | Rule | How it is checked |
|---|---|---|
| MUST | Required stories produce no axe violations at the configured severity. | Automated by npm run test:stories:matrix:ci. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by npm run test:stories:hc. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-05-28. |
| MUST NOT | Maintainers: Do not bypass design tokens or skip forced-colors verification at beta. | Release review; not machine-checked. |
Install and import
- Install:
npm install @digitaltableteur/react(version 0.9.1, restricted access on npm). - Import:
import { ThemeProvider } from "@digitaltableteur/react"; - Entry point:
@digitaltableteur/react/runtimeexports it too. - Styles: import
@digitaltableteur/react/style.cssonce at the app boundary.
Links
- Machine-readable contract (Design System Contract 1.0)
- Markdown version of this page
- Component index as JSON
- All components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.