Switch

Switches allow users to toggle between two states, on or off. On mobile, these are often used as a replacement for checkboxes.

Switch

Maven Central Class reference Source code

Default

Day Night
Switch component Switch component - dark mode

Installation

Backpack Compose is available through Maven Central. Check the main Readme for a complete installation guide.

Usage

Example of a Switch:


                                                
                                                import net.skyscanner.backpack.compose.switch.BpkSwitch
                                                
                                                BpkSwitch(
                                                  text = "Switch text",
                                                  checked = true,
                                                  onCheckedChange = { checked -> },
                                                )

Example of a Switch with custom content:


                                                
                                                import net.skyscanner.backpack.compose.switch.BpkSwitch
                                                
                                                BpkSwitch(
                                                  checked = true,
                                                  onCheckedChange = { checked -> },
                                                ) { checked ->
                                                  MyCustomContent()
                                                }