Toggle

Displays a boolean value.

General

The basic Toggle usage.

Type

Differentiate states by color.

With Icons

Show an icon inside the thumb with icon, and a different one when checked with checkedIcon.

Disabled

You can change disabled Toggle with the property disabled.

Get Change

Capture changes in Toggle.

Notification settings

Put the label and what it does on the left and the Toggle on the right, and name each switch with aria-label.

APIs

Toggle.Props

AttributeDescriptionTypeAccepted valuesDefault
checkedchecked or notboolean--
initialCheckedchecked or not on initialboolean-false
onChangechange event handlerToggleEvent--
typecurrent typeToggleTypesToggleTypesdefault
disableddisable toggleboolean-false
iconicon inside the thumbReactNode--
checkedIconicon when checked, falls back to iconReactNode--
...native propsLabelHTMLAttributes'from', 'name', 'className', ...-

ToggleEvent

interface ToggleEventTarget {
  checked: boolean
}

export interface ToggleEvent {
  target: ToggleEventTarget
  stopPropagation: () => void
  preventDefault: () => void
  nativeEvent: React.ChangeEvent
}

ToggleTypes

type ToggleTypes =
  | 'default'
  | 'primary'
  | 'secondary'
  | 'success'
  | 'warning'
  | 'error'
  | 'info'
Edit this page on GitHub