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
UsageBehaviorBest practicesUsageBehaviorBest practices

Usage

Basic implementation

<rh-scheme-toggle></rh-scheme-toggle>

With custom labels

<rh-scheme-toggle
  legend-text="Theme selection"
  light-text="Light theme"
  dark-text="Dark theme"
  system-text="Auto theme">
</rh-scheme-toggle>

Setting initial scheme

<rh-scheme-toggle scheme="dark"></rh-scheme-toggle>

Behavior

Persistence

The scheme toggle automatically:

  • Saves the selected scheme to localStorage so it persists across browser sessions
  • Restores the saved preference on page load

System preference

When "System" is selected, the toggle:

  • Sets color-scheme: light dark to respect user's OS preference
  • Allows the browser/OS to determine the appropriate scheme
  • Updates automatically when system preferences change

Best practices

Supporting color-scheme in your page CSS

Placement

  • Consider mobile placement, scheme toggles can be moved to drawers in mobile navs.
  • Group with other appearance/preference controls when appropriate

Integration

  • Setting the color scheme via the toggle applies the selected scheme to the entire document, by setting the color-scheme property on the body.
  • Write your page CSS using light-dark() to take advantage of this.
  • RHDS elements already use light-dark() internally, so if you follow our theming guidelines, you'll get this for free.

User experience

  • Provides immediate visual feedback when scheme changes
  • Respects user's initial system preference as the default, avoid setting the scheme attribute
  • Don't override user selections without explicit consent

Other libraries

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

© 2025 Red Hat Deploys by Netlify