Chips are compact elements that represent an input, attribute, or action.
Chips allow users to enter information, make selections, filter content, or trigger actions.
While included here as a standalone component, the most common use will be in some form of input, so some of the behavior demonstrated here is not shown in context.
The Chip
component supports outlined and filled styling.
{{ādemoā: āBasicChips.jsā}}
You can use the following actions.
onClick
prop defined change appearance on focus, hover, and click.onDelete
prop defined will display a delete icon which changes appearance on hover.{{ādemoā: āClickableChips.jsā}}
{{ādemoā: āDeletableChips.jsā}}
{{ādemoā: āClickableAndDeletableChips.jsā}}
{{ādemoā: āClickableLinkChips.jsā}}
{{ādemoā: āCustomDeleteIconChips.jsā}}
You can add ornaments to the beginning of the component.
Use the avatar
prop to add an avatar or use the icon
prop to add an icon.
{{ādemoā: āAvatarChips.jsā}}
{{ādemoā: āIconChips.jsā}}
You can use the color
prop to define a color from theme palette.
{{ādemoā: āColorChips.jsā}}
You can use the size
prop to define a small Chip.
{{ādemoā: āSizesChips.jsā}}
By default, Chips displays labels only in a single line.
To have them support multiline content, use the sx
prop to add height:auto
to the Chip component, and whiteSpace: normal
to the label
styles.
{{ādemoā: āMultilineChips.jsā}}
An example of rendering multiple chips from an array of values.
Deleting a chip removes it from the array. Note that since no
onClick
prop is defined, the Chip
can be focused, but does not
gain depth while clicked or touched.
{{ādemoā: āChipsArray.jsā}}
{{ādemoā: āChipsPlayground.jsā, āhideToolbarā: true}}
If the Chip is deletable or clickable then it is a button in tab order. When the Chip is focused (for example when tabbing) releasing (keyup
event) Backspace
or Delete
will call the onDelete
handler while releasing Escape
will blur the Chip.