Skip to main content Red Hat Design System logo Contribute on Github v2.0.0 Home
About About the design systemHow we buildRoadmap
Get started OverviewDesignersDevelopers
Foundations OverviewColorGridPersonalization patternsSpacingTypography
Tokens Overview Global colorBox shadowTypographyBorderOpacitySpaceLengthIconBreakpointsMedia queries
Elements All elements Accordion Alert Audio player Avatar Back to top Badge Blockquote Breadcrumb Button Call to action Card Code block Dialog Footer Health index Icon Navigation (primary)Planned Navigation (secondary) Pagination PopoverPlanned Progress stepsPlanned Site status Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed
Patterns All patternsAnnouncementCardDisclosureFilterFormLinkLink with iconLogo wallSearch barSkip navigationSticky bannerSticky cardTabsTileVideo thumbnail
Accessibility FundamentalsContentDesignDevelopmentContributorsQa and testingAssistive technologiesResources
Design/code status Release notes Get support

Switch

Overview Style Guidelines Code Demos Accessibility
  1. Installation
  2. Usage
  3. rh-switch
  1. Installation
  2. Usage
  3. rh-switch

Installation

Usage

<rh-switch id="a" checked></rh-switch>
<label for="a">
  <span data-state="on">Message when on</span>
  <span data-state="off" hidden>Message when off</span>
</label>

rh-switch

Slots 0

None

Attributes 8
DOM Property Description Type Default
label
string | undefined
unknown
showCheckIcon
boolean
false
checked
boolean
false
disabled
boolean
false
accessibleLabel
string | undefined
unknown
messageOn
string | undefined
unknown
messageOff
string | undefined
unknown
reversed
boolean
false
Methods 1
Method Name Description
formDisabledCallback(disabled: boolean)
Events 1
Event Name Description
change
CSS Shadow Parts 0

None

CSS Custom Properties 3
CSS Property Description Default
--rh-switch-unchecked

The background color of the switch when it is unchecked.

--rh-switch-checked

The background color of the switch when it is checked.

--rh-switch-disabled

The background color of the switch when it is disabled.

Design Tokens 0

None

© 2021-2024 Red Hat, Inc. Deploys by Netlify