Back to Fluentui

Switch Migration

packages/react-components/react-switch/library/docs/MIGRATION.md

4.40.2-hotfix23.1 KB
Original Source

Switch Migration

Migration from v8's Toggle

Props that remain as is

  • checked
  • defaultChecked

Props that have the same name but have a different implementation

  • as - Uses new pattern for as introduced in v9
  • label - Now implemented as a v9 slot
  • onChange - Has a slightly different API with our new event data handling pattern

Props removed because we can get them from HTML props

  • ariaLabel => Getting it as aria-label instead
  • disabled
  • role

Props no longer supported with an equivalent funtionality in v9's Switch

  • as
  • componentRef => Use regular ref instead
  • inlineLabel => Use labelPosition instead
  • styles => Use new styling system via tokens instead

Props no longer supported without an equivalent functionality in v9's Switch

  • offText
  • onText
  • theme

Migration from v0's Checkbox

Props that remain as is

  • checked
  • defaultChecked
  • labelPosition

Props that have the same name but have a different implementation

  • as - Uses new pattern for as introduced in v9
  • indicator => Now implemented as a v9 slot
  • label - Now implemented as a v9 slot
  • onChange - Has a slightly different API with our new event data handling pattern

Props removed because we can get them from HTML props

  • className
  • disabled
  • onClick

Props no longer supported with an equivalent functionality in v9's Switch

  • accessibility => Override accessibility behavior by composing the Switch however you want
  • styles => Use new styling system via tokens instead
  • toggle => Default behavior for Switch in v9
  • variables => Use new styling system via tokens instead

Props no longer supported without an equivalent functionality in v9's Switch

  • design

Property mapping

v8 Togglev0 Checkboxv9 Switch
accessibility
arialabelaria-labelaria-label
asasas
checkedcheckedchecked
classNameclassNameclassName
componentRefref
defaultChecked
design
disableddisableddisabled
indicatorindicator
inlineLabellabelPositionlabelPosition
labellabellabel
offText
onChangeonChangeonChange
onClickonClickonClick
onText
rolerole
stylesstyles
theme
Default behaviortoggleDefault behavior
variables