Created
April 12, 2025 07:30
-
-
Save JyotimoyKashyap/e083f955c9febcc843d4ec11a842ee1b to your computer and use it in GitHub Desktop.
Search Bar for Icons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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