Skip to main content Home
About About the Design SystemRoadmap
Get started OverviewDesignersDevelopers
Foundations OverviewColorGridIconographyInteractionsSpacingTypography
Tokens Overview Global colorbox shadowTypographyborderopacityspacelengthIconBreakpointsMedia Queries
Elements All elements Accordion Alert Announcement Audio player Avatar Back to top Badge Blockquote Breadcrumb Button Card Chip Code block Call to action Dialog Disclosure Footer Health index Icon Jump links Navigation (primary) Navigation (secondary) Pagination PopoverPlanned Progress stepper Scheme toggle Site status Skeleton Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed
Theming OverviewColor PalettesCustomizingDevelopers
Patterns All PatternsCardFilterFormLink with iconLogo wallSearch barSticky bannerSticky cardTabsTagTile
Personalization All Personalization PatternsAnnouncement
Accessibility FundamentalsAccessibility toolsAssistive technologiesCI/CDContentContributorsDesignDevelopmentManual testingResourcesScreen readers
Design/code status Release notes Get support

Scheme toggle

OverviewStyleGuidelinesCodeAccessibilityDemos
ImportingUsagerh-scheme-toggleImportingUsagerh-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 Wrap 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 Wrap lines

rh-scheme-toggle

A switch toggles the state of the color scheme (between light, dark and system default).

Slots 0
None
Attributes 5
Attribute DOM Property Description Type Default
scheme scheme

Current color scheme setting

Scheme
globalThis.localStorage\n ?.rhdsColorScheme as Scheme
legend-text legendText

Legend text for the color scheme toggle group

string
'Color scheme'
light-text lightText

Label text for the light mode option

string
'Light'
dark-text darkText

Label text for the dark mode option

string
'Dark'
system-text systemText

Label text for the system default option

string
'System'
Methods 0
None
Events 0
None
CSS Shadow Parts 0
None
CSS Custom Properties 0
None
Design Tokens 13
Token Copy
--rh-space-lg
Full CSS Variable Permalink to this token
--rh-size-icon-01
Full CSS Variable Permalink to this token
--rh-color-border-subtle
Full CSS Variable Permalink to this token
--rh-space-2xl
Full CSS Variable Permalink to this token
--rh-space-3xl
Full CSS Variable Permalink to this token
--rh-border-radius-default
Full CSS Variable Permalink to this token
--rh-color-interactive-secondary-focus
Full CSS Variable Permalink to this token
--rh-color-interactive-primary-active
Full CSS Variable Permalink to this token
--rh-color-border-interactive
Full CSS Variable Permalink to this token
--rh-color-text-primary-on-dark
Full CSS Variable Permalink to this token
--rh-color-text-primary-on-light
Full CSS Variable Permalink to this token
--rh-border-width-sm
Full CSS Variable Permalink to this token
--rh-color-interactive-primary-focus
Full CSS Variable Permalink to this token

Other libraries

To learn more about our other libraries, visit the getting started page.

© 2025 Red Hat Deploys by Netlify