Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/js-bhavyansh/segmented_buttons

Segmented button UI in Jetpack Compose with dynamic options and customizable styles.
https://github.com/js-bhavyansh/segmented_buttons

android-studio jetpack-compose kotlin material-ui segmented-button

Last synced: 2 days ago
JSON representation

Segmented button UI in Jetpack Compose with dynamic options and customizable styles.

Awesome Lists containing this project

README

        

# Segmented Buttons UI in Jetpack Compose

This project showcases a segmented button UI using Jetpack Compose's `SingleChoiceSegmentedButtonRow`. It allows for easy navigation between different options with a visually appealing design.

## Features

- Dynamic segmented buttons with selectable options.
- Smooth transitions between different segments.
- Customizable button shapes and styles.

## Screenshots


First Screenshot
Second Screenshot

## Installation

1. Clone the repository:
```sh
git clone https://github.com/Bhavyansh03-tech/Segmented_Buttons.git
```

2. Open the project in Android Studio.

3. Sync the project with Gradle files.

## Usage

To use the segmented button UI in your project, integrate the `SingleChoiceSegmentedButtonRow` and `SegmentedButton` composables as shown below:

```kotlin
@OptIn(ExperimentalMaterial3Api::class)
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
SegmentedButtonsTheme {

var selectedIndex by remember {
mutableIntStateOf(0)
}

val options = remember {
mutableStateListOf("Music", "Movies", "Podcasts")
}

Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center
) {
SingleChoiceSegmentedButtonRow {
options.forEachIndexed { index, option ->
SegmentedButton(
selected = selectedIndex == index,
onClick = { selectedIndex = index },
shape = SegmentedButtonDefaults.itemShape(
index = index,
count = options.size
)
) {
Text(text = option)
}
}
}
}
}
}
}
}
```

## Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.

1. Fork the repository.
2. Create your feature branch (`git checkout -b feature/your-feature`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin feature/your-feature`).
5. Create a new Pull Request.

## Contact

For questions or feedback, please contact [@Bhavyansh03-tech](https://github.com/Bhavyansh03-tech).

---