JGuang

Switch

Switch · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Switch

Mutually exclusive operation controls, users can turn on or turn off a certain function.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: Basic usage.
  • Type: There are three types of switches to choose from.
  • Disabled: Set Switch to be disabled by disabled.
  • Size: You can get switches of different sizes by specifying size.
  • Customize text: Customize the text or icon to be displayed when the switch is turned on (off).
  • With Icon: Customize the icon displayed on the switch button.
  • Loading: The Switch is in the loading state and cannot be clicked.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

Switch

PropertyDescriptionTypeDefaultValue
checkedTo set checkedboolean-
defaultCheckedTo set default checkedboolean-
disabledWhether to disableboolean-
loadingLoading stateboolean-
sizeThe size of the switch'small' | 'default'-
typeThree style types'circle' | 'round' | 'line'circle
checkedIconThe icon displayed on the button when the switch is turned onReactNode-
checkedTextThe text when the switch is turned on, the small size does not work.ReactNode-
uncheckedIconThe icon displayed on the button when the switch is offReactNode-
uncheckedTextThe text when the switch is turned off, the small size does not work.ReactNode-
classNameAdditional css classstring | string[]-
styleAdditional styleCSSProperties-
onChangeCallback when click(value: boolean, event) => void-