MaterialUIKit
Github
  • MaterialUIKit
  • Essentials
    • Configuring and Personalizing
    • Defining a Custom Color Schemes
  • Configuration and Color Schemes
    • MUIKitConfiguration
    • MUIKitColorScheme
  • Components
    • Action Button
      • ActionButtonStyle
    • Checkbox
    • Collection
      • CollectionStyle
    • Container
    • Date Selector
    • Dialog
    • Dialog Sheet
    • Dropdown Menu
      • Dropdown Menu Label
    • FAB
    • Icon Button
      • IconButtonStyle
    • Navigation Container
      • NavigationContainerHeaderStyle
      • Navigation Route
      • Navigation Route Label
    • Progress Bar
    • Radio Buttons Group
    • Search Box
    • Secure Text Box
    • Segmented Buttons
    • Separator
      • SeparatorOrientationStyle
    • Snackbar
    • Switch
    • Time Selector
    • Text Box
    • Tab Bar
      • TabBar Item
Powered by GitBook
On this page
  • Overview
  • Initializer
  • Parameters
  • Example
  1. Components

Switch

Represents a Material UI styled switch for toggling boolean states.

Overview

The Switch view is used to toggle a boolean state on or off with a Material UI style switch. It allows users to toggle between checked and unchecked states.

To use the Switch, initialize it with a title key and a binding to the boolean state.

Initializer

Creates a switch with a specified title and state binding.

Switch(_ titleKey: String, isOn: Binding<Bool>)

Parameters

Parameter

Description

titleKey

The title key of the switch.

isOn

A binding to a boolean value that determines the on/off state of the switch.

Example

@State private var isSwitchOn = false

var body: some View {
    Container {
        Switch("Toggle Switch", isOn: $isTurnedOn)
    }
}
PreviousSnackbarNextTime Selector

Last updated 10 months ago