Search
MaterialComponentsDocs
Components overviewApp barBadgeButtonsButton groupButtonExtended FABFAB menuFABIcon buttonSplit buttonCardCarouselCheckboxChipsDate & time pickersDate pickerTime pickerDialogDividerListLoading & progressLoading indicatorProgressMenuNavigationNavigation barNavigation drawerNavigation railRadio buttonsSearchSelectSheetsBottom sheetSide sheetSliderSnackbarSwitchTabsText fieldToolbarTooltip

Chips

Explore compact choices and actions. Try the four chip types, elevation, icons and avatars, and single or multiple selection.

HikingMusicFood
FactoryWeb ComponentsReactVueSvelteSolidJS
PublishedUpdated

Chips are compact elements that stand for one discrete thing. M3 has four types: assist chips for a smart or automated action, filter chips to narrow content, input chips for something the user entered, such as a recipient, and suggestion chips for a generated suggestion, such as a reply.

createChips builds a set, which owns the selection, removal and keyboard navigation of its chips; createAssistChip, createFilterChip, createInputChip and createSuggestionChip build one chip on its own.

Usage

A set is multi-select unless multiSelect is false. Its chips are configurations, which the set builds; without a type, a chip in a set is a filter chip.

Vanilla
import { createChips } from 'material';

const chips = createChips({
  label: 'Categories',
  chips: [
    { type: 'filter', label: 'JavaScript', value: 'js' },
    { type: 'filter', label: 'TypeScript', value: 'ts' },
    { type: 'filter', label: 'CSS', value: 'css' },
  ],
});
document.body.append(chips.element);
Web Components
<m-chips label="Categories">
  <m-chip value="js" variant="filter">JavaScript</m-chip>
  <m-chip value="ts" variant="filter">TypeScript</m-chip>
  <m-chip value="css" variant="filter">CSS</m-chip>
</m-chips>
React
import { Chips, Chip } from 'material/react';

export function Example() {
  return (
    <Chips label="Categories">
      <Chip value="js" variant="filter">JavaScript</Chip>
      <Chip value="ts" variant="filter">TypeScript</Chip>
      <Chip value="css" variant="filter">CSS</Chip>
    </Chips>
  );
}
Vue
<script setup lang="ts">
import { MChips, MChip } from 'material/vue';
</script>

<template>
  <MChips label="Categories">
    <MChip value="js" variant="filter">JavaScript</MChip>
    <MChip value="ts" variant="filter">TypeScript</MChip>
    <MChip value="css" variant="filter">CSS</MChip>
  </MChips>
</template>
Svelte
<script lang="ts">
  import { Chips, Chip } from 'material/svelte';
</script>

<Chips label="Categories">
  <Chip value="js" variant="filter">JavaScript</Chip>
  <Chip value="ts" variant="filter">TypeScript</Chip>
  <Chip value="css" variant="filter">CSS</Chip>
</Chips>
SolidJS
import { Chips, Chip } from 'material/solid';

export function Example() {
  return (
    <Chips label="Categories">
      <Chip value="js" variant="filter">JavaScript</Chip>
      <Chip value="ts" variant="filter">TypeScript</Chip>
      <Chip value="css" variant="filter">CSS</Chip>
    </Chips>
  );
}

change reports the selection as one object, { value, selected, changed }. value is the set's current value: an array in a multi-select set, a string or null in a single-select one. The web component's detail has value.

Examples

Single selection

selectionRequired keeps the last selected chip selected, in either mode.

Vanilla
import { createChips } from 'material';

const chips = createChips({
  label: 'Size',
  multiSelect: false,
  selectionRequired: true,
  chips: [
    { type: 'filter', label: 'S', value: 's' },
    { type: 'filter', label: 'M', value: 'm', selected: true },
    { type: 'filter', label: 'L', value: 'l' },
  ],
});
document.body.append(chips.element);
Web Components
<m-chips value="m" selection-required label="Size" selection="single">
  <m-chip value="s" variant="filter">S</m-chip>
  <m-chip value="m" variant="filter">M</m-chip>
  <m-chip value="l" variant="filter">L</m-chip>
</m-chips>
React
import { useState } from 'react';
import { Chips, Chip } from 'material/react';

export function Example() {
  const [value, setValue] = useState("m");
  return (
    <Chips value={value} onChange={(event) => setValue(event.detail.value)} selectionRequired label="Size" selection="single">
      <Chip value="s" variant="filter">S</Chip>
      <Chip value="m" variant="filter">M</Chip>
      <Chip value="l" variant="filter">L</Chip>
    </Chips>
  );
}
Vue
<script setup lang="ts">
import { ref } from 'vue';
import { MChips, MChip } from 'material/vue';

const value = ref("m");
</script>

<template>
  <MChips v-model="value" selection-required label="Size" selection="single">
    <MChip value="s" variant="filter">S</MChip>
    <MChip value="m" variant="filter">M</MChip>
    <MChip value="l" variant="filter">L</MChip>
  </MChips>
</template>
Svelte
<script lang="ts">
  import { Chips, Chip } from 'material/svelte';

  let value = $state("m");
</script>

<Chips bind:value selectionRequired label="Size" selection="single">
  <Chip value="s" variant="filter">S</Chip>
  <Chip value="m" variant="filter">M</Chip>
  <Chip value="l" variant="filter">L</Chip>
</Chips>
SolidJS
import { createSignal } from 'solid-js';
import { Chips, Chip } from 'material/solid';

export function Example() {
  const [value, setValue] = createSignal("m");
  return (
    <Chips value={value()} onChange={(event) => setValue(event.detail.value)} selectionRequired label="Size" selection="single">
      <Chip value="s" variant="filter">S</Chip>
      <Chip value="m" variant="filter">M</Chip>
      <Chip value="l" variant="filter">L</Chip>
    </Chips>
  );
}

Input chips

Every input chip has a remove button, and Backspace or Delete removes it when focused. In a set, the set removes it and emits remove with { value, chip, chipValue }; on its own, it leaves the page. avatar puts a 24dp round image in place of the leading icon.

Vanilla
import { createChips } from 'material';

const chips = createChips({
  label: 'To',
  chips: [
    { type: 'input', label: 'Ada Lovelace', value: '[email protected]' },
    { type: 'input', label: 'Alan Turing', value: '[email protected]' },
  ],
});
document.body.append(chips.element);
Web Components
<m-chips label="To">
  <m-chip value="[email protected]" variant="input">Ada Lovelace</m-chip>
  <m-chip value="[email protected]" variant="input">Alan Turing</m-chip>
</m-chips>
React
import { Chips, Chip } from 'material/react';

export function Example() {
  return (
    <Chips label="To">
      <Chip value="[email protected]" variant="input">Ada Lovelace</Chip>
      <Chip value="[email protected]" variant="input">Alan Turing</Chip>
    </Chips>
  );
}
Vue
<script setup lang="ts">
import { MChips, MChip } from 'material/vue';
</script>

<template>
  <MChips label="To">
    <MChip value="[email protected]" variant="input">Ada Lovelace</MChip>
    <MChip value="[email protected]" variant="input">Alan Turing</MChip>
  </MChips>
</template>
Svelte
<script lang="ts">
  import { Chips, Chip } from 'material/svelte';
</script>

<Chips label="To">
  <Chip value="[email protected]" variant="input">Ada Lovelace</Chip>
  <Chip value="[email protected]" variant="input">Alan Turing</Chip>
</Chips>
SolidJS
import { Chips, Chip } from 'material/solid';

export function Example() {
  return (
    <Chips label="To">
      <Chip value="[email protected]" variant="input">Ada Lovelace</Chip>
      <Chip value="[email protected]" variant="input">Alan Turing</Chip>
    </Chips>
  );
}

Assist chips

elevated gives assist, filter and suggestion chips the elevated style in place of the outline.

Vanilla
import { createChips } from 'material';

const chips = createChips({
  label: 'Actions',
  chips: [
    {
      type: 'assist',
      label: 'Add to calendar',
      value: 'calendar',
      leadingIcon: calendarIcon,
      elevated: true,
    },
    {
      type: 'assist',
      label: 'Directions',
      value: 'directions',
      leadingIcon: locationIcon,
      elevated: true,
    },
  ],
});
document.body.append(chips.element);
Web Components
<m-chips label="Actions">
  <m-chip value="calendar" variant="assist" elevated>Add to calendar</m-chip>
  <m-chip value="directions" variant="assist" elevated>Directions</m-chip>
</m-chips>

<script type="module">
  const chips = document.querySelector('m-chips');
  chips.querySelector('m-chip[value="calendar"]').setAttribute('icon', calendarIcon);
  chips.querySelector('m-chip[value="directions"]').setAttribute('icon', locationIcon);
</script>
React
import { Chips, Chip } from 'material/react';
import { calendarIcon, locationIcon } from './app';

export function Example() {
  return (
    <Chips label="Actions">
      <Chip value="calendar" variant="assist" icon={calendarIcon} elevated>Add to calendar</Chip>
      <Chip value="directions" variant="assist" icon={locationIcon} elevated>Directions</Chip>
    </Chips>
  );
}
Vue
<script setup lang="ts">
import { MChips, MChip } from 'material/vue';
import { calendarIcon, locationIcon } from './app';
</script>

<template>
  <MChips label="Actions">
    <MChip value="calendar" variant="assist" :icon="calendarIcon" elevated>Add to calendar</MChip>
    <MChip value="directions" variant="assist" :icon="locationIcon" elevated>Directions</MChip>
  </MChips>
</template>
Svelte
<script lang="ts">
  import { Chips, Chip } from 'material/svelte';
  import { calendarIcon, locationIcon } from './app';
</script>

<Chips label="Actions">
  <Chip value="calendar" variant="assist" icon={calendarIcon} elevated>Add to calendar</Chip>
  <Chip value="directions" variant="assist" icon={locationIcon} elevated>Directions</Chip>
</Chips>
SolidJS
import { Chips, Chip } from 'material/solid';
import { calendarIcon, locationIcon } from './app';

export function Example() {
  return (
    <Chips label="Actions">
      <Chip value="calendar" variant="assist" icon={calendarIcon} elevated>Add to calendar</Chip>
      <Chip value="directions" variant="assist" icon={locationIcon} elevated>Directions</Chip>
    </Chips>
  );
}

A filter chip's trailingMenu gives it a trailing button that opens a menu; onTrailingClick handles it. A filter chip opening a price menu is planned for Showcase. A chip your app makes draggable shows M3's dragged state from dragstart to dragend; material does not move chips itself.

API

Options

A chip

Passed to the four factories, and in a set's chips or addChip(), with type.

type

In a set's chips or addChip(); the factories set it

Type'assist' | 'filter' | 'input' | 'suggestion'
Default'filter'
label

The chip's label

Typestring
Default''
value

Identifies the chip to its set and to forms

Typestring
Defaultderived from the label
leadingIcon

Leading icon as SVG markup (icon is an alias)

Typestring
Defaultundefined
trailingIcon

Trailing icon as SVG markup; not on suggestion chips. On an input chip it replaces the remove icon

Typestring
Defaultundefined
avatar

Input chips: a 24dp round avatar (markup), in place of the leading icon

Typestring
Defaultundefined
elevated

Assist, filter and suggestion chips: the elevated style

Typeboolean
Defaultfalse
selected

Filter and input chips: whether the chip starts selected

Typeboolean
Defaultfalse
disabled

Whether the chip starts disabled

Typeboolean
Defaultfalse
removeLabel

Input chips: the remove button's accessible name

Typestring
Default'Remove {label}'
onRemove

Input chips: called when the chip is removed

Type(chip) => void
Defaultundefined
onTrailingClick

Filter chips: gives the trailing icon its own button

Type(chip) => void
Defaultundefined
trailingMenu

Filter chips: the trailing button opens a menu (aria-haspopup, a drop-down arrow)

Typeboolean
Defaultfalse
trailingLabel

Filter chips: the trailing button's accessible name

Typestring
Default'{label} options' or 'Remove {label}'
onClick

Called when the chip is activated, before it toggles: isSelected() is still the state before the click

TypeChipEvents['click']
Defaultundefined
onChange

Filter and input chips: called when a click changes the selected state

Type(payload: { selected, chip, value }) => void
Defaultundefined
onSelect

Filter and input chips: called with the chip after onChange

Type(chip) => void
Defaultundefined
ripple

Whether a press shows the ripple

Typeboolean
Defaulttrue
class

Additional CSS classes

Typestring
Defaultundefined
prefix

Prefix for CSS class names

Typestring
Default'mtrl'

A set

Passed to createChips.

chips

The chips to build and manage

TypeChipConfig[]
Default[]
multiSelect

Whether several chips can be selected at once

Typeboolean
Defaulttrue
selectionRequired

Whether the last selected chip is kept selected

Typeboolean
Defaultfalse
label

A visible label that names the set

Typestring
Defaultundefined
labelPosition

Which side the label sits on

Type'start' | 'end'
Default'start'
scrollable

Whether the set scrolls horizontally instead of wrapping

Typeboolean
Defaultfalse
vertical

Whether the chips stack vertically

Typeboolean
Defaultfalse
onChange

Called with the selection after the change

Type(event: { value, selected, changed }) => void
Defaultundefined
on

Event handlers registered at creation

Type{ change?, add?, remove? }
Defaultundefined
class

Additional CSS classes

Typestring
Defaultundefined
prefix

Prefix for CSS class names

Typestring
Default'mtrl'

Methods

A chip

setLabel(text) / getLabel()

The label (setText / getText are aliases)

Parameterstext: string
ReturnsChipComponent / string
setLeadingIcon(icon) / getIcon()

The leading icon (setIcon is an alias)

Parametersicon: string
ReturnsChipComponent / string
setTrailingIcon(icon)

The trailing icon, or an input chip's remove icon

Parametersicon: string
ReturnsChipComponent
setSelected(selected) / toggleSelected() / isSelected()

Selection, for filter and input chips

Parametersselected: boolean
ReturnsChipComponent / boolean
setValue(value) / getValue()

The chip's value

Parametersvalue: string
ReturnsChipComponent / string | null
enable() / disable() / isDisabled()

The disabled state

Parametersnone
ReturnsChipComponent / boolean
getType()

The chip's type

Parametersnone
ReturnsChipType
focus()

Focuses the chip's action

Parametersnone
ReturnsChipComponent
addClass(...classes)

Adds classes to the chip

Parameters...classes: string[]
ReturnsChipComponent
on(event, handler) / off(event, handler)

Adds or removes a listener

Parametersevent: string, handler: Function
ReturnsChipComponent
destroy()

Removes listeners and the element

Parametersnone
Returnsvoid

chip.action is the chip's native button. An input chip's remove button and a filter chip's trailing button (chip.trailingAction) are its siblings, never inside it.

A set

addChip(config) / removeChip(chipOrIndex)

Adds or removes a chip

Parametersconfig: ChipConfig / chipOrIndex: ChipComponent | number
ReturnsChipsComponent
getChips() / getSelectedChips()

The chips, or the selected ones

Parametersnone
ReturnsChipComponent[]
getSelectedValues()

The selected values, in either mode

Parametersnone
Returns(string | null)[]
getValue() / setValue(values)

An array when multi-select, a string or null when single-select

Parametersvalues: string | string[] | null
Returnsstring | string[] | null / ChipsComponent
selectByValue(values, triggerEvent?) / clearSelection()

Programmatic selection

Parametersvalues: string | string[], triggerEvent?: boolean
ReturnsChipsComponent
setScrollable(on) / setVertical(on)

Layout

Parameterson: boolean
ReturnsChipsComponent
setLabel(text) / getLabel()

The set's label

Parameterstext: string
ReturnsChipsComponent / string
setLabelPosition(position) / getLabelPosition()

Which side the label sits on

Parametersposition: 'start' | 'end'
ReturnsChipsComponent / string
scrollToChip(chipOrIndex)

Scrolls a scrollable set to a chip

ParameterschipOrIndex: ChipComponent | number
ReturnsChipsComponent
enableKeyboardNavigation()

Enables the arrow-key navigation between chips

Parametersnone
ReturnsChipsComponent
on(event, handler) / off(event, handler)

Adds or removes a listener

Parametersevent: string, handler: Function
ReturnsChipsComponent
destroy()

Removes the set

Parametersnone
Returnsvoid

Events

Chip click

The chip was activated

Payload{ event, element, originalEvent }
Chip change

A click changed the selected state

Payload{ selected, chip, value }
Chip remove / trailing

Removed, or its trailing button activated

Payloadthe chip
Chip focus / blur / keydown

The chip's action took or lost focus, or a key went down

Payload{ event, element, originalEvent }
Set change

The selection changed

Payload{ value, selected, changed }; changed is null for programmatic changes
Set add

A chip was added

Payload{ value, chip }
Set remove

A chip is about to be removed

Payload{ value, chip, chipValue }

The web component's change carries { value }, and remove the removed chip's { value }.

Styling

Colors come from the theme's roles; --mtrl-chip-label-color, --mtrl-chip-leading-color, --mtrl-chip-trailing-color and --mtrl-chip-checkmark-color set a chip's parts.

.mtrl-chip { }
.mtrl-chip--assist, .mtrl-chip--filter, .mtrl-chip--input, .mtrl-chip--suggestion { }
.mtrl-chip--elevated, .mtrl-chip--selected, .mtrl-chip--disabled, .mtrl-chip--dragged { }
.mtrl-chip--leading, .mtrl-chip--trailing, .mtrl-chip--avatar { }  /* the parts shown */
.mtrl-chip__action { }          /* the native button */
.mtrl-chip__leading-icon, .mtrl-chip__checkmark, .mtrl-chip__label, .mtrl-chip__trailing-icon { }
.mtrl-chip__remove, .mtrl-chip__trailing-action { }

.mtrl-chips { }
.mtrl-chips--scrollable, .mtrl-chips--vertical, .mtrl-chips--with-label, .mtrl-chips--label-end { }
.mtrl-chips__container, .mtrl-chips__label { }

Measurements

From the m3.material.io chips specs and Compose's chip tokens.

Attribute Value
Height 32dp
Corner 8dp
Outline 1dp outline-variant, inside the chip; none when selected or elevated
Padding 16dp without icons, 8dp beside an icon, 4dp beside an avatar
Icon 18dp, 8dp from the label
Avatar 24dp, round
Label Label Large
Selected secondary-container
Elevated surface-container-low at elevation 1
Touch target 48dp
Motion The checkmark and leading icon expand on the fast spatial spring and fade