Docplanner Logo

Docplanner Mobile UI

Edit page
Introduction
⚙️ – Core
⚛️ – Atoms-Molecules
AvatarBadgeButtonCheckBoxFieldCircleDividerDownloadCardIconInputFieldInputFieldButtonLinkListItemOneTimeCodeInputPhotoAvatarRadioGroupFieldRatingSelectFieldSimpleAvatarSpacerSwitchFieldPropertiesBasic usageError stateSwitch with loading exampleTextToast❌ Icon (Deprecated)❌ Roboto (Deprecated)❌ WorkSans (Deprecated)
🧬 – Organisms

SwitchField

A switch allows users to turn things ON or OFF, like a light switch. We can use them when needing to perform instantaneous actions that do not need a review or confirmation, or defining a isLoading prop to show a spinner.

Properties

label
ReactNode
required

Switch label

error
string | undefined

Error message

switchStyle
ViewStyle | undefined

Style that applies to the container of the switch.

value
boolean
required

Flag to trigger the movement of the thumb of the switch from one side to the other.

onValueChange
(value: boolean) => void
required

Callback called when after a click the user release the switch, it pass the future value of the switch. Even if the switch is passing the next value the user should set the isActive value to trigger the changes.

isLoading
boolean | undefined

Flag used to show an internal spinner.

isDisabled
boolean | undefined

Flag used to make not clickable the spinner.

inActiveTrackColor
"gray" | "blue" | "turquoise" | "purple" | "red" | "yellow" | "green" | "transparent" | "blue50" | "blue100" | "blue200" | "blue300" | "blue400" | "blue500" | "blue600" | "blue700" | ... 64 more ... | undefined

Change the inactive color of the background of the switch, default is gray300.

activeTrackColor
"gray" | "blue" | "turquoise" | "red" | "green" | "primary" | undefined

Change the active color of the background of the switch, default is blue.

thumbColor
"gray" | "blue" | "turquoise" | "purple" | "red" | "yellow" | "green" | "transparent" | "blue50" | "blue100" | "blue200" | "blue300" | "blue400" | "blue500" | "blue600" | "blue700" | ... 64 more ... | undefined

Change the thumb color of the switch, default is white.

testID
string | undefined
accessibilityLabel
string | undefined

Basic usage

<Switch /> does not render properly here. Please fire up the demo app to see what it really looks like.

Error state

Switch with loading example