Skip to content

Switch - Usage ​

The Switch component allows users to toggle between two states.

AndroidreleasedElementsreleasediOSreleasedReactreleasedVuereleased

iOS ​

Syntax ​

swift
Warp.Switch(
    isOn: Binding<Bool>,
    state: Warp.SwitchState = .default
)
swift
Warp.Switch(isOn: $isOn)

Visual options ​

There are a variety of variants supported for the Switch component:

swift
enum Warp.SwitchState {
    case `default`
    case disabled
}

Legacy support ​

By default all Warp components return a SwiftUI View but there is always a UIKit UIView available to use also.

swift
Warp.Switch(isOn: $isOn).uiView

Parameters ​

Required props ​

NameTypeDefaultDescription
isOnBinding BoolBinding to a Boolean value indicating whether the switch is on or off.

Optional Props ​

NameTypeDefaultDescription
stateWarp.SwitchState.defaultThe state of the switch. Use one of the predefined SwitchState values: .default, or .disabled

Questions? ​

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system