Skip to content
RefineUI

Switch

Immediate toggle switch for settings.

Overview

Machine-readable contract from Component Spec.

component: switchexport: Switchversion: 1tokens.visual: switchattributes: data-refineui=switch

Anatomy

Partdata-refineui
rootswitch

States

ScopeCategoryValues
componentpseudofocus-visible
componentenvironmentforced-colors, dir, prefers-contrast

Accessibility

SlotElementRoleNative
switchbuttonswitchtrue

Keyboard

KeyActionNative
Enteractivatetrue
Spaceactivatetrue

Focus

SectionPropertyValue
visualrequiredtrue
visualselector:focus-visible

Layout

PropertyValue
directionlogical
rtltrue

Variant

Select a recipe variant — preview and Recipe → Tokens update together.

Recipe → Tokens

Slot bindings for variant="on" — declared in Toggle/style → switch tokens.

SlotVariantPropertyTraceSemanticLight → foundationDark → foundationRecipe class
trackonbackgroundswitch.track.onbackgroundBrandprimaryBlackprimaryGraybg-refineui-alias-background-brand
thumbbackgroundswitch.thumb.defaultbackgroundPrimaryneutralWhiteneutral900bg-refineui-alias-background-primary

Component token trace

All paths in token-trace-v2.json prefixed with switch.

TraceSemanticLight foundationDark foundationLightDark
switch.thumb.defaultbackgroundPrimaryneutralWhiteneutral900#FFFFFF#1A1A1A
switch.thumb.disabledOffbackgroundBrandSubtleprimaryLightGrayneutral800#E6E6E6#2A2A2A
switch.thumb.disabledOnbackgroundPrimaryneutralWhiteneutral900#FFFFFF#1A1A1A
switch.track.activeOffbackgroundBrandSubtleprimaryLightGrayneutral800#E6E6E6#2A2A2A
switch.track.activeOnbackgroundBrandActiveneutralBlackprimaryLightGray#000000#E6E6E6
switch.track.disabledOffbackgroundSurfaceDisabledneutral150neutral850#F0F0F0#222222
switch.track.disabledOnbackgroundBrandSubtleprimaryLightGrayneutral800#E6E6E6#2A2A2A
switch.track.hoverOffbackgroundSurfaceSelectedneutral200neutral650#EBEBEB#5B5B5B
switch.track.hoverOnbackgroundBrandHoverprimaryDarkGrayprimaryLightGray#4d4d4d#E6E6E6
switch.track.offbackgroundPrimaryActiveneutral150neutral800#F0F0F0#2A2A2A
switch.track.onbackgroundBrandprimaryBlackprimaryGray#212121#D4D4D4
npm install @refineui/react @refineui/tokens
import { Switch } from "@refineui/react";
<Switch checked={isEnabled} onCheckedChange={setIsEnabled} />
<Switch
checked={darkMode}
onCheckedChange={setDarkMode}
aria-label="Toggle dark mode"
/>
PropDefaultTypeDescription
checkedbooleanControlled checked state.
onCheckedChange(checked: boolean) => voidEvent handler when checked state changes.
disabledfalsebooleanDisables interaction.