switchy-compose
0.7.2indexedCustomizable switch component library enhances Android UI with animated switches, multiple styles, and configurations. Offers smooth transitions, minimal dependencies, and Material Design compliance.
Customizable switch component library enhances Android UI with animated switches, multiple styles, and configurations. Offers smooth transitions, minimal dependencies, and Material Design compliance.
Surfaced from shared tags and platforms — no rankings paid for.
A modern, customizable switch component library for Jetpack Compose that provides beautiful animated switches with various styles and configurations, now with multiplatform support!
The library is available on Maven Central. No additional repository setup is required.
dependencies {
implementation("dev.muazkadan:switchy-compose:0.7.2")
}
commonMain.dependencies {
implementation("dev.muazkadan:switchy-compose:0.7.2")
}
@Composable
fun MyScreen() {
var switchValue by remember { mutableStateOf(false) }
ISwitch(
checked = switchValue,
onCheckedChange = { switchValue = it }
)
}
var switchValue by rememberSaveable { mutableStateOf(false) }
TextSwitch(
modifier = Modifier.padding(horizontal = 16.dp),
checked = switchValue,
positiveText = "ON",
negativeText = "OFF",
onCheckedChange = { switchValue = it }
)
var switchValue by rememberSaveable { mutableStateOf(false) }
ColoredSwitch(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
checked = switchValue,
positiveColor = Color.Green,
negativeColor = Color.Red,
onCheckedChange = { switchValue = it }
)
var switchValue by rememberSaveable { mutableStateOf(false) }
ISwitch(
checked = switchValue,
buttonHeight = 40.dp,
positiveColor = Color(0xFF35C759),
negativeColor = Color(0xFFE9E9EA),
onCheckedChange = { switchValue = it }
)
var switchValue by rememberSaveable { mutableStateOf(false) }
IconISwitch(
checked = switchValue,
positiveIcon = Icons.Default.Done,
negativeIcon = Icons.Default.Close,
onCheckedChange = { switchValue = it }
)
var switchValue by rememberSaveable { mutableStateOf(false) }
CustomISwitch(
checked = switchValue,
positiveContent = {
Icon(
imageVector = Icons.Default.Done,
contentDescription = null,
tint = Color.White
)
},
negativeContent = {
Text(
text = "OFF",
color = Color.Gray,
fontSize = 10.sp
)
},
onCheckedChange = { switchValue = it }
)
var switchValue by rememberSaveable { mutableStateOf(false) }
CustomSwitch(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
checked = switchValue,
positiveContent = {
Icon(
imageVector = Icons.Default.Done,
contentDescription = null
)
},
negativeContent = {
Text("OFF")
},
onCheckedChange = { switchValue = it }
)
var switchValue by rememberSaveable { mutableStateOf(false) }
SquareSwitch(
modifier = Modifier.padding(horizontal = 16.dp),
checked = switchValue,
shape = RoundedCornerShape(4.dp),
onCheckedChange = { switchValue = it }
)
var checked by rememberSaveable { mutableStateOf(false) }
NativeSwitch(
checked = checked,
onCheckedChange = { checked = it },
modifier = Modifier.padding(horizontal = 16.dp),
enabled = true
)
modifier: Modifier for the switchswitchValue: Current state of the switchonValueChanged: Callback when switch state changesshape: Custom shape for the switchpositiveColor/: Colors for different statesbuttonHeight: Height of the switch buttoninnerPadding: Padding inside the switch thumbpositiveContent/negativeContent: Custom composable contentContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Have an awesome custom Compose switch you'd like to share? We'd love to include it in Switchy Compose! Whether it's a unique animation, a creative design, or a platform-specific style, your custom switch could enhance the library. To contribute:
TextSwitch, ISwitch).app module to showcase your switch.The project includes a demo app showcasing all switch variants. To run the demo:
app modulegit checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)Copyright 2023 Muaz KADAN
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
Made with ❤️ by Muaz KADAN | LinkedIn
Add the JitPack repository to your project's settings.gradle file:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Or in your project-level build.gradle file:
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation("com.github.muazkadan:switchy-compose:0.7.2")
}
negativeColor