Skip to main content
Version: Next

switch

README.md

:OCSwitch - A Custom Composable UI Component

This OCSwitch is a custom Jetpack Compose component designed to toggle its state to On or Off.

Features:

  • Configurable control with customizable colors.
  • Create switch with active, inactive, selected and deselected states.

:How to use OCSwitch

  1. Add the necessary imports:

    import your.package.name.OCSwitch

  2. Use the OCSwitch within your Composable:

     val switchState = remember { mutableStateOf(true) }
    val activeStatus = remember { mutableStateOf(false) }
    OCSwitch(
    isOn = switchState.value,
    isEnabled = activeStatus.value,
    onSwitchToggled = {
    switchState.value = it
    },
    )

Parameters:

  • isOn: Boolean denotes if switch is On of Off state.
  • isSelected: Boolean denotes if switch is enabled or disabled.
  • switchConfig: (Optional) Configuration to change style of the switch.
  • onSwitchToggled: A lambda function called when a switch is toggled.