Scheme toggle
On this page
Overview
A scheme toggle provides users with the ability to switch between light, dark, and system default color schemes. It should be placed in a visible location for easy access. For WCAG compliance, screen reader users must be able to identify each option; the component uses a native fieldset with ARIA-compatible radio buttons. Tab focuses the group; arrow keys allow selection between schemes.
Edit element properties
import '@rhds/elements/rh-scheme-toggle/rh-scheme-toggle.js';
body {
color-scheme: light dark;
background-color: light-dark(var(--rh-color-surface-lightest, #ffffff),
var(--rh-color-surface-darkest, #151515));
color: light-dark(var(--rh-color-text-primary-default-on-light, #151515),
var(--rh-color-text-primary-default-on-dark, #ffffff));
}
<rh-scheme-toggle></rh-scheme-toggle>
import { SchemeToggle } from "@rhds/elements/react/rh-scheme-toggle/rh-scheme-toggle.js";
// NOTE: React 19+ does not require these wrapper imports.
// You can use the custom elements directly as-is.
export const Demo = () => (
<SchemeToggle />
);
Current color scheme setting. Reflects to the scheme attribute and
initializes from localStorage.rhdsColorScheme when available.
When set, applies the value to document.body.style.colorScheme
and persists it to localStorage.
Legend text displayed next to the toggle button group. Authors should keep this text short (under 20 characters).
Accessible label for the light mode radio button.
Rendered as a visually-hidden span and a title tooltip.
Accessible label for the dark mode radio button.
Rendered as a visually-hidden span and a title tooltip.
Accessible label for the system default radio button.
Rendered as a visually-hidden span and a title tooltip.
Status
- Figma library:
-
Ready - RH Elements:
-
Ready - RH Shared Libs:
-
Planned
When to use
- Provide system-responsive theme options that respect user preferences
- Build applications that support multiple color schemes
- Allow users to switch between light and dark color schemes
Status checklist
| Property | Status | Meaning |
|---|---|---|
| Figma library |
|
Component is available in the Figma library |
| RH Elements |
|
Component is available in RH Elements |
| RH Shared Libs |
|
Component will be added to RH Shared Libs |
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.