CamoSearchField
A search field: the search icon, the keyboard's Search action (Enter on desktop and web) calling onSearch,
and a "Clear search" button while there's text, which clears and keeps focus. Esc clears too. leading
replaces the search icon (a back button when a search is open); trailing adds e.g. a mic. Debouncing is the
app's: the field reports every change. With autoFocus the field takes focus when it first appears (a search
that opens on its own, such as the command palette's).
API
- Kotlin
- Dart
public fun CamoSearchField(
query: String,
onQueryChange: (String) -> Unit,
onSearch: (String) -> Unit,
modifier: Modifier = Modifier,
placeholder: String = "Search",
leading: (@Composable () -> Unit)? = null,
trailing: (@Composable () -> Unit)? = null,
enabled: Boolean = true,
onFocusChanged: ((Boolean) -> Unit)? = null,
interactionSource: MutableInteractionSource? = null,
autoFocus: Boolean = false,
)
| Name | Type | Default |
|---|---|---|
query | String | required |
onQueryChange | (String) -> Unit | required |
onSearch | (String) -> Unit | required |
modifier | Modifier | Modifier |
placeholder | String | "Search" |
leading | (@Composable () -> Unit)? | null |
trailing | (@Composable () -> Unit)? | null |
enabled | Boolean | true |
onFocusChanged | ((Boolean) -> Unit)? | null |
interactionSource | MutableInteractionSource? | null |
autoFocus | Boolean | false |
Design notes
Why CamoSearchField works this way, its states and its edge cases: contributor docs.