Scheme toggle
Importing
Add rh-scheme-toggle to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-scheme-toggle/rh-scheme-toggle.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
Usage
<rh-scheme-toggle></rh-scheme-toggle>
<script type="module">
import '@rhds/elements/rh-scheme-toggle/rh-scheme-toggle.js';
</script>
<style>
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));
}
</style>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-scheme-toggle
A scheme toggle switches between light, dark, and system default color schemes.
Slots
0
Attributes
5
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
scheme
|
scheme |
Current color scheme setting |
|
|
legend-text
|
legendText |
Legend text for the color scheme toggle group |
|
|
light-text
|
lightText |
Label text for the light mode option |
|
|
dark-text
|
darkText |
Label text for the dark mode option |
|
|
system-text
|
systemText |
Label text for the system default option |
|
|
Methods
0
None
Events
0
None
CSS Shadow Parts
0
None
CSS Custom Properties
0
None
Design Tokens
13
| Token | Description | Copy |
|---|---|---|
--rh-space-lg
|
16px spacer |
|
--rh-size-icon-01
|
16px icon box |
|
--rh-color-border-subtle
|
|
|
--rh-space-2xl
|
32px spacer |
|
--rh-space-3xl
|
48px spacer |
|
--rh-border-radius-default
|
3px border radius; Example: Card |
|
--rh-color-interactive-secondary-focus
|
|
|
--rh-color-interactive-primary-active
|
|
|
--rh-color-border-interactive
|
|
|
--rh-color-text-primary-on-dark
|
Primary text color for dark theme |
|
--rh-color-text-primary-on-light
|
Primary text color for light theme |
|
--rh-border-width-sm
|
1px border width; Example: Secondary CTA or Button |
|
--rh-color-interactive-primary-focus
|
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.