Skip to main content

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​

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​

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,
)
NameTypeDefault
valueT?
onValueChange(T) -> Unitrequired
optionsList<SelectOption<T>>required
modifierModifierModifier
labelString?null
placeholderString?null
supportingTextString?null
errorString?null
presentationSelectPresentationSelectPresentation.Auto
searchableBooleanfalse
prefixIcon(@Composable () -> Unit)?null
enabledBooleantrue
Design notes

Why CamoSelect works this way, its states and its edge cases: contributor docs.