🌈 Create new beautiful Compose Gradients with our new wesite ->

Picker

Picker preview
Kotlin
@Composable
fun SimplePicker() {
    val items = listOf("One", "Two", "Three", "Four", "Five")
    val state = rememberPickerState(items.size)
    // We forward scroll gestures from the whole screen to the Picker which makes this sample
    // accessible for 2-finger vertical scrolling.
    Box(
        modifier =
            Modifier.fillMaxSize()
                .scrollable(
                    state = state,
                    orientation = Orientation.Vertical,
                    reverseDirection = true,
                ),
        contentAlignment = Alignment.Center,
    ) {
        val selectedLabel by remember {
            derivedStateOf { "Selected: ${items[state.selectedOptionIndex]}" }
        }
        Text(
            modifier = Modifier.align(Alignment.TopCenter).padding(top = 10.dp),
            text = selectedLabel,
        )
        Picker(
            modifier = Modifier.size(100.dp, 100.dp),
            state = state,
            contentDescription = { "${state.selectedOptionIndex + 1}" },
        ) {
            Text(items[it])
        }
    }
}