← Back to Material 3 Compose
FilterChip
Overview
Code Examples
<a href="https://m3.material.io/components/chips/overview" class="external" target="_blank">Material Design filter chip</a>.
Chips help people enter information, make selections, filter content, or trigger actions. Chips can show multiple interactive elements together in the same area, such as a list of selectable movie times, or a series of email contacts.
Filter chips use tags or descriptive words to filter content. They can be a good alternative to toggle buttons or checkboxes.
!Filter chip image(https://developer.android.com/images/reference/androidx/compose/material3/filter-chip.png)
This filter chip is applied with a flat style. If you want an elevated style, use the ElevatedFilterChip.
Tapping on a filter chip toggles its selection state. A selection state leadingIcon can be provided (e.g. a checkmark) to be appended at the starting edge of the chip's label.
Example of a flat FilterChip with a trailing icon:
Overloads
FilterChip
@ExperimentalMaterial3Api
@Composable
fun FilterChip(
selected: Boolean,
onClick: () -> Unit,
label: @Composable () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
leadingIcon: @Composable (() -> Unit)? = null,
trailingIcon: @Composable (() -> Unit)? = null,
shape: Shape = FilterChipDefaults.shape,
colors: SelectableChipColors = FilterChipDefaults.filterChipColors(),
elevation: SelectableChipElevation? = FilterChipDefaults.filterChipElevation(),
border: SelectableChipBorder? = FilterChipDefaults.filterChipBorder(),
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }
)
Parameters
Name | Description |
---|---|
selected | whether this chip is selected or not |
onClick | called when this chip is clicked |
label | text label for this chip |
modifier | the Modifier to be applied to this chip |
enabled | controls the enabled state of this chip. When false , this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services. |
leadingIcon | optional icon at the start of the chip, preceding the label text. When selected is true, this icon may visually indicate that the chip is selected (for example, via a checkmark icon). |
trailingIcon | optional icon at the end of the chip |
shape | defines the shape of this chip's container, border (when border is not null), and shadow (when using elevation) |
colors | SelectableChipColors that will be used to resolve the colors used for this chip in different states. See FilterChipDefaults.filterChipColors. |
elevation | SelectableChipElevation used to resolve the elevation for this chip in different states. This controls the size of the shadow below the chip. Additionally, when the container color is ColorScheme.surface, this controls the amount of primary color applied as an overlay. See FilterChipDefaults.filterChipElevation. |
border | the border to draw around the container of this chip. Pass null for no border. See FilterChipDefaults.filterChipBorder. |
interactionSource | the MutableInteractionSource representing the stream of Interactions for this chip. You can create and pass in your own remember ed instance to observe Interactions and customize the appearance / behavior of this chip in different states |