Skip to content

Instantly share code, notes, and snippets.

@JyotimoyKashyap
Created April 12, 2025 07:30
Show Gist options
  • Select an option

  • Save JyotimoyKashyap/e083f955c9febcc843d4ec11a842ee1b to your computer and use it in GitHub Desktop.

Select an option

Save JyotimoyKashyap/e083f955c9febcc843d4ec11a842ee1b to your computer and use it in GitHub Desktop.
Search Bar for Icons
@Composable
fun SearchBar(onTextChange: (String) -> Unit = {}) {
val searchString = remember { mutableStateOf("") }
Row {
OutlinedTextField(
value = searchString.value,
onValueChange = {
searchString.value = it
onTextChange(it)
},
singleLine = true,
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = MaterialTheme.spacing.medium,
vertical = MaterialTheme.spacing.small
),
label = {
Text(
text = stringResource(R.string.search_field_placeholder_text),
style = MaterialTheme.typography.bodyMedium
)
},
textStyle = MaterialTheme.typography.bodyMedium,
leadingIcon = {
Icon(
imageVector = Icons.Filled.Search,
contentDescription = stringResource(R.string.search_field_placeholder_text)
)
},
shape = MaterialTheme.shapes.extraLarge
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment