KPicker - farimarwat/KrossUi GitHub Wiki

🔽 KPicker Component Documentation

A multiplatform (Android + iOS) simple wheel-style picker for Kotlin apps, useful for selecting a single item from a list.


🔹 Overview

Element Type Description
KPicker Composable Platform-adaptive single item picker UI.

🧩 KPicker

Definition:
A lightweight picker component that displays a scrollable list of items and notifies when an item is selected. Suitable for date pickers, option selectors, and other similar UI elements.

Parameters

Parameter Type Default Description
items List<String> The list of items to be displayed in the picker.
onItemSelected (String) -> Unit Callback function triggered when an item is selected.
modifier Modifier Modifier Modifier to style or position the picker.
colors KPickerColors KPickerDefaults.colors() Defines text and background color for the picker.

🎨 KPickerColors

Defines color configuration for the picker component.

Property Type Description
backgroundColor Color Background color of the picker container.
textColor Color Text color for picker items.

⚙️ KPickerDefaults

Provides default color values for KPicker.

colors(...)

Parameter Type Default Value Description
backgroundColor Color Color.LightGray Background color for the picker container.
textColor Color Color.Black Color of the picker items text.

Returns a KPickerColors instance with the provided or default values.


✅ Usage Example

val fruits = listOf("Apple", "Mango", "Grapes", "Pineapple", "Banana")

KPicker(
    modifier = Modifier.fillMaxWidth(),
    items = fruits,
    onItemPicked = { selectedItem ->
        println("Picked: $selectedItem")
    }
)

🔹 Note:

  • items is a list of strings to display in the picker.
  • onItemPicked returns the selected item as a string.
  • Picker adapts natively: shows a spinner on Android and wheel picker on iOS.
⚠️ **GitHub.com Fallback** ⚠️