CamoSelect
Picks one of options: a read-only field (the text field's frame with the skin's dropdown chevron) that
opens the options in a menu under it or in a bottom sheet (presentation). Auto uses the menu for up to
SelectTheme.autoMenuMaxOptions options on a window at least autoMenuMinWidth wide, and the sheet
otherwise, and always when searchable (the sheet then has a search field filtering by label, ignoring
case and accents). Picking an option calls onValueChange and closes; Esc or an outside tap closes without
a change. A value that isn't among the options shows as value.toString().
Usage
- Kotlin
- Dart
var country by remember { mutableStateOf<String?>(null) }
CamoSelect(
value = country,
onValueChange = { country = it },
options = listOf(
SelectOption("id", "Indonesia"),
SelectOption("nl", "Netherlands"),
SelectOption("us", "United States"),
),
label = "Country",
placeholder = "Choose one",
searchable = true,
)
API
- Kotlin
- Dart
public fun <T> CamoSelect(
value: T?,
onValueChange: (T) -> Unit,
options: List<SelectOption<T>>,
modifier: Modifier = Modifier,
label: String? = null,
placeholder: String? = null,
supportingText: String? = null,
error: String? = null,
presentation: SelectPresentation = SelectPresentation.Auto,
searchable: Boolean = false,
prefixIcon: (@Composable () -> Unit)? = null,
enabled: Boolean = true,
)
| Name | Type | Default |
|---|---|---|
value | T? | |
onValueChange | (T) -> Unit | required |
options | List<SelectOption<T>> | required |
modifier | Modifier | Modifier |
label | String? | null |
placeholder | String? | null |
supportingText | String? | null |
error | String? | null |
presentation | SelectPresentation | SelectPresentation.Auto |
searchable | Boolean | false |
prefixIcon | (@Composable () -> Unit)? | null |
enabled | Boolean | true |
Design notes
Why CamoSelect works this way, its states and its edge cases: contributor docs.