Skip to content

Material 3

Components

Chip

Chips help people enter information, make selections, filter content, or trigger actions.

9:30
Amenities
Washer / Dryer
Ramp access
Garden
Cats OK
Dogs OK
Smoke free
Neighborhoods
Eaglehead
Rabbit Island
Downtown
Harbor

Chips help people enter information, make selections, filter content, or trigger actions. They appear together as a group, in a row of options.

For an action that stands alone, use a button instead.

Chips are written in a group, with these parts:

PartUse
ChipGroupThe group, which lays out its chips in rows and sets whether they act, select or are removed. See Chip actions.
ChipA chip, whose variant sets its type
import { Chip, ChipGroup, Icon, IconButton } from '@material-web/react'
import { Text } from 'react-aria-components'

Basic chip

Put each Chip in a ChipGroup, and write the chip's label as its children. A Chip outside a ChipGroup throws an error. The group lays out its chips in rows that wrap onto the next line.

Vegan
Gluten free
Organic
Local
import { Chip, ChipGroup, Icon } from '@material-web/react'

const diets = ['Vegan', 'Gluten free', 'Organic', 'Local']

export default function Basic() {
  return (
    <ChipGroup aria-label="Diet" selectionMode="multiple" defaultSelectedKeys={['vegan']}>
      {diets.map((diet) => (
        <Chip key={diet} id={diet.toLowerCase()} variant="filter" textValue={diet}>
          {({ isSelected }) => (
            <>
              {isSelected && <Icon slot="leading" name="check" />}
              {diet}
            </>
          )}
        </Chip>
      ))}
    </ChipGroup>
  )
}

A chip is named by its textValue. A chip whose children are a plain string uses that string as its textValue. Any other chip requires a textValue: one whose children are a function, or hold an icon or a Text label.

The Chip comes in four variants. Set variant to assist, filter, input or suggestion. It is required and has no default.

Assist
Filter
Input
Suggestion
import { Chip, ChipGroup, Icon } from '@material-web/react'

export default function Variants() {
  return (
    <ChipGroup aria-label="Variants">
      <Chip id="assist" variant="assist" textValue="Assist">
        <Icon slot="leading" name="event" />
        Assist
      </Chip>
      <Chip id="filter" variant="filter" textValue="Filter">
        Filter
        <Icon slot="trailing" name="arrow_drop_down" />
      </Chip>
      <Chip id="input" variant="input" textValue="Input">
        <Icon slot="leading" name="person" />
        Input
      </Chip>
      <Chip id="suggestion" variant="suggestion">
        Suggestion
      </Chip>
    </ChipGroup>
  )
}

Assist chip

Assist chips represent smart or automated actions that can span multiple apps. Handle a press with onAction on the chip, or with onAction on the group, which is called with the id of the chip.

Add to calendar
Get directions
Share

No action yet

import { Chip, ChipGroup, Icon } from '@material-web/react'
import { useState } from 'react'
import type { Key } from 'react-aria-components'

export default function Assist() {
  const [action, setAction] = useState<Key>()
  return (
    <div className="flex flex-col items-center gap-space-200">
      <ChipGroup aria-label="Actions" onAction={setAction}>
        <Chip id="calendar" variant="assist" textValue="Add to calendar">
          <Icon slot="leading" name="event" />
          Add to calendar
        </Chip>
        <Chip id="directions" variant="assist" textValue="Get directions">
          <Icon slot="leading" name="directions" />
          Get directions
        </Chip>
        <Chip id="share" variant="assist" textValue="Share">
          <Icon slot="leading" name="share" />
          Share
        </Chip>
      </ChipGroup>
      <p className="m-0 text-body-md text-on-surface-variant">
        {action ? `Last action: ${action}` : 'No action yet'}
      </p>
    </div>
  )
}

Filter chip

Filter chips represent filters for a collection. Set selectionMode on the group to single or multiple, and give each chip an id. Control the selection with selectedKeys and onSelectionChange, or set the initial selection with defaultSelectedKeys. See React Aria's Selection guide.

A selected filter chip has no checkmark unless you add one: put an Icon in the leading slot while the chip isSelected, as in this example.

Sort by
Price
Rating
Distance
import { Chip, ChipGroup, Icon } from '@material-web/react'
import { useState } from 'react'
import type { Selection } from 'react-aria-components'

const orders = ['Price', 'Rating', 'Distance']

export default function Filter() {
  const [selected, setSelected] = useState<Selection>(new Set(['price']))
  return (
    <div className="flex flex-col items-center gap-space-150">
      <span id="sort-by" className="text-title-sm text-on-surface">
        Sort by
      </span>
      <ChipGroup
        aria-labelledby="sort-by"
        selectionMode="single"
        selectedKeys={selected}
        onSelectionChange={setSelected}
      >
        {orders.map((order) => (
          <Chip key={order} id={order.toLowerCase()} variant="filter" textValue={order}>
            {({ isSelected }) => (
              <>
                {isSelected && <Icon slot="leading" name="check" />}
                {order}
              </>
            )}
          </Chip>
        ))}
      </ChipGroup>
    </div>
  )
}

Input chip

Input chips represent discrete pieces of information entered by a person. Handle their removal with onRemove on the group. It is called with the ids of the chips to remove when a chip's remove button is pressed, or on Backspace or Delete on a chip.

Add the remove button as an IconButton with slot="remove". It is named by its aria-label and the chip's label. A Button from react-aria-components with slot="remove" is named Remove, in the current locale, unless you set an aria-label.

Ann Lee
Bo Chen
Cy Park
import { Chip, ChipGroup, Icon, IconButton } from '@material-web/react'
import { Text, useListData } from 'react-aria-components'

export default function Input() {
  const people = useListData({
    initialItems: [
      { id: 'ann', name: 'Ann Lee' },
      { id: 'bo', name: 'Bo Chen' },
      { id: 'cy', name: 'Cy Park' },
    ],
  })
  return (
    <ChipGroup
      aria-label="Recipients"
      items={people.items}
      onRemove={(keys) => people.remove(...keys)}
      renderEmptyState={() => (
        <span className="text-body-md text-on-surface-variant">No recipients</span>
      )}
    >
      {(person) => (
        <Chip variant="input" textValue={person.name}>
          <Icon slot="leading" name="person" />
          <Text slot="label">{person.name}</Text>
          <IconButton slot="remove" aria-label="Remove">
            <Icon name="close" />
          </IconButton>
        </Chip>
      )}
    </ChipGroup>
  )
}

In this example, a function renders the chips from the group's items, and renderEmptyState renders what the group shows after the last chip is removed. See Chip array.

Suggestion chip

Suggestion chips help narrow a person's intent by presenting dynamically generated suggestions, such as what to say or search next. Handle a press with onAction, as on an assist chip.

What song is this?
What are the lyrics?
Who is the artist?

Nothing asked yet

import { Chip, ChipGroup } from '@material-web/react'
import { useState } from 'react'
import type { Key } from 'react-aria-components'

const questions = ['What song is this?', 'What are the lyrics?', 'Who is the artist?']

export default function Suggestion() {
  const [asked, setAsked] = useState<Key>()
  return (
    <div className="flex w-full max-w-96 flex-col gap-space-200">
      <ChipGroup aria-label="Suggestions" onAction={setAsked}>
        {questions.map((question) => (
          <Chip key={question} id={question} variant="suggestion">
            {question}
          </Chip>
        ))}
      </ChipGroup>
      <p className="m-0 text-body-md text-on-surface-variant">
        {asked ? `Asked: ${asked}` : 'Nothing asked yet'}
      </p>
    </div>
  )
}

Elevated chip

Set isElevated to give a chip its own container with a shadow. Use it for a chip that needs more visual separation, such as on an image or a dynamic background. An input chip is always flat, and its types do not accept isElevated.

Assist
Filter
Suggestion
import { Chip, ChipGroup, Icon } from '@material-web/react'

export default function Elevated() {
  return (
    <div className="rounded-shape-lg bg-tertiary-container p-space-600">
      <ChipGroup aria-label="Elevated" selectionMode="multiple" defaultSelectedKeys={['filter']}>
        <Chip id="assist" variant="assist" isElevated textValue="Assist">
          <Icon slot="leading" name="event" />
          Assist
        </Chip>
        <Chip id="filter" variant="filter" isElevated textValue="Filter">
          {({ isSelected }) => (
            <>
              {isSelected && <Icon slot="leading" name="check" />}
              Filter
            </>
          )}
        </Chip>
        <Chip id="suggestion" variant="suggestion" isElevated>
          Suggestion
        </Chip>
      </ChipGroup>
    </div>
  )
}

Slots

  1. leading
  2. label
  3. trailing
  4. remove
SlotChildUse
leadingAn Icon or an imageBefore the label, on every chip. See Avatars and Icons.
labelA TextThe label, on every chip. See Long labels.
trailingAn Icon or a buttonAfter the label, on a filter chip. See Trailing button.
removeA buttonThe remove button, after the label, on an input chip. An input chip has no trailing slot.

Set slot on a child to place it in one of the chip's slots. A child is placed by its slot, in whatever order the children are written. See Slots.

Note: An Icon or a button with a slot that its chip does not have throws an Invalid slot error, and so does a button with no slot. Any other element with another slot is shown where it is written, and so is an Icon with no slot.

Avatars

Put an image in a chip to show an avatar, in the leading slot or with no slot. It is shown round, at the start of the chip.

Ann Lee
Bo Chen
import { Chip, ChipGroup, Icon, IconButton } from '@material-web/react'
import { Text, useListData } from 'react-aria-components'

const avatar = (initial: string, color: string) =>
  `data:image/svg+xml,${encodeURIComponent(
    `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48"><rect width="48" height="48" fill="${color}"/><text x="24" y="32" font-family="sans-serif" font-size="24" fill="white" text-anchor="middle">${initial}</text></svg>`,
  )}`

export default function Avatar() {
  const people = useListData({
    initialItems: [
      { id: 'ann', name: 'Ann Lee', avatar: avatar('A', '#6750a4') },
      { id: 'bo', name: 'Bo Chen', avatar: avatar('B', '#386a20') },
    ],
  })
  return (
    <ChipGroup aria-label="Guests" items={people.items} onRemove={(keys) => people.remove(...keys)}>
      {(person) => (
        <Chip variant="input" textValue={person.name}>
          <img slot="leading" alt="" src={person.avatar} />
          <Text slot="label">{person.name}</Text>
          <IconButton slot="remove" aria-label="Remove">
            <Icon name="close" />
          </IconButton>
        </Chip>
      )}
    </ChipGroup>
  )
}

Icons

Put an icon in the leading or trailing slot. An Icon is sized and colored for the chip, unless a class on the icon sets its own size or color. Any icon works in a slot.

Leading icon
Trailing icon
Both
Under $50
import { Chip, ChipGroup, Icon, IconButton } from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'

export default function Slots() {
  const [price, setPrice] = useState('Under $50')
  return (
    <ChipGroup aria-label="Slots">
      <Chip id="leading" variant="assist" textValue="Leading icon">
        <Icon slot="leading" name="event" />
        Leading icon
      </Chip>
      <Chip id="trailing" variant="filter" textValue="Trailing icon">
        Trailing icon
        <Icon slot="trailing" name="arrow_drop_down" />
      </Chip>
      <Chip id="both" variant="filter" textValue="Both">
        <Icon slot="leading" name="sell" />
        Both
        <Icon slot="trailing" name="arrow_drop_down" />
      </Chip>
      <Chip id="price" variant="filter" textValue={price}>
        <Text slot="label">{price}</Text>
        <IconButton slot="trailing" aria-label="Clear price" onPress={() => setPrice('Any price')}>
          <Icon name="close" />
        </IconButton>
      </Chip>
    </ChipGroup>
  )
}

Trailing button

A chip can hold a button after its label. On an input chip, it is the remove button, with slot="remove". On a filter chip, it is any button with slot="trailing": give it its own aria-label and onPress, as on the last chip of the example above. It is disabled with the chip. An assist or suggestion chip takes no button.

Chip array

Write the chips as the group's children, or pass items with a function as children that returns a chip for each item, as with React Aria's collections. The group also accepts dependencies for that function, and renderEmptyState for the content of an empty group.

In this example, both groups render their chips from an array in state. Removing a chip takes it out of the first array, and pressing a suggestion adds it.

Basil
Garlic
Olives
Peppers
Onions
import { Chip, ChipGroup, Icon, IconButton } from '@material-web/react'
import { useState } from 'react'
import { Text } from 'react-aria-components'

const toppings = [
  { id: 'basil', name: 'Basil' },
  { id: 'garlic', name: 'Garlic' },
  { id: 'olives', name: 'Olives' },
  { id: 'peppers', name: 'Peppers' },
  { id: 'onions', name: 'Onions' },
]

export default function ChipArray() {
  const [added, setAdded] = useState(toppings.slice(0, 2))
  const others = toppings.filter((topping) => !added.includes(topping))
  return (
    <div className="flex w-full max-w-96 flex-col gap-space-200">
      <ChipGroup
        aria-label="Toppings"
        items={added}
        onRemove={(keys) => setAdded(added.filter((topping) => !keys.has(topping.id)))}
        renderEmptyState={() => (
          <span className="text-body-md text-on-surface-variant">No toppings</span>
        )}
      >
        {(topping) => (
          <Chip variant="input" textValue={topping.name}>
            <Text slot="label">{topping.name}</Text>
            <IconButton slot="remove" aria-label="Remove">
              <Icon name="close" />
            </IconButton>
          </Chip>
        )}
      </ChipGroup>
      <ChipGroup
        aria-label="More toppings"
        items={others}
        onAction={(id) => setAdded([...added, toppings.find((topping) => topping.id === id)!])}
      >
        {(topping) => (
          <Chip variant="suggestion" textValue={topping.name}>
            <Icon slot="leading" name="add" />
            {topping.name}
          </Chip>
        )}
      </ChipGroup>
    </div>
  )
}

A chip takes the id of its item unless you set one. For the ids, the text values and dependencies, see Collections. To keep the array in state with methods that add and remove items, use React Aria's useListData, as the input chips do.

Chip actions

What the chips do is set on their group: the chips of a group act, select or are removed together.

ActionSet on the ChipGroupKeyboardExample
Act on a pressonAction, called with the id of the chipEnterAssist chip
SelectselectionMode, with selectedKeys and onSelectionChangeSpace or EnterFilter chip
RemoveonRemove, with a remove button in each chipBackspace or DeleteInput chip

Only filter and input chips show selection.

Selectable and removable chips

Set both selectionMode and onRemove on a group for chips that can be selected and removed. Backspace or Delete on a selected chip removes every selected chip.

Travel
Food
Music
Film
import { Chip, ChipGroup, Icon, IconButton } from '@material-web/react'
import { Text, useListData } from 'react-aria-components'

export default function SelectableRemovable() {
  const tags = useListData({
    initialItems: [
      { id: 'travel', name: 'Travel' },
      { id: 'food', name: 'Food' },
      { id: 'music', name: 'Music' },
      { id: 'film', name: 'Film' },
    ],
  })
  return (
    <ChipGroup
      aria-label="Tags"
      items={tags.items}
      selectionMode="multiple"
      onRemove={(keys) => tags.remove(...keys)}
    >
      {(tag) => (
        <Chip variant="input" textValue={tag.name}>
          <Text slot="label">{tag.name}</Text>
          <IconButton slot="remove" aria-label="Remove">
            <Icon name="close" />
          </IconButton>
        </Chip>
      )}
    </ChipGroup>
  )
}

Disabled

Disable a chip with its own isDisabled, or with disabledKeys on the group. A disabled chip cannot be selected or removed, and a button in it is disabled too.

Assist
Filter
Suggestion
Enabled
import { Chip, ChipGroup, Icon } from '@material-web/react'

export default function Disabled() {
  return (
    <ChipGroup aria-label="Disabled" selectionMode="multiple" disabledKeys={['filter']}>
      <Chip id="assist" variant="assist" isDisabled textValue="Assist">
        <Icon slot="leading" name="event" />
        Assist
      </Chip>
      <Chip id="filter" variant="filter">
        Filter
      </Chip>
      <Chip id="suggestion" variant="suggestion" isElevated isDisabled>
        Suggestion
      </Chip>
      <Chip id="enabled" variant="filter">
        Enabled
      </Chip>
    </ChipGroup>
  )
}

Color

A variant sets the chip's colors. To use other color roles, pass their classes in className, with a state variant for the colors of a state. In this example, a selected chip takes the tertiary container colors in place of the secondary ones.

Jazz
Soul
Funk
Disco
import { Chip, ChipGroup, Icon } from '@material-web/react'

const genres = ['Jazz', 'Soul', 'Funk', 'Disco']

export default function Colors() {
  return (
    <ChipGroup aria-label="Genres" selectionMode="multiple" defaultSelectedKeys={['jazz', 'funk']}>
      {genres.map((genre) => (
        <Chip
          key={genre}
          id={genre.toLowerCase()}
          variant="filter"
          textValue={genre}
          className="selected:bg-tertiary-container selected:text-on-tertiary-container"
        >
          {({ isSelected }) => (
            <>
              {isSelected && <Icon slot="leading" name="check" />}
              {genre}
            </>
          )}
        </Chip>
      ))}
    </ChipGroup>
  )
}

Long labels

The label of a chip is one line. Write it as the chip's text, or as a Text with slot="label":

  • A Text label is cut short with an ellipsis in a chip too narrow for it. A chip is never wider than its group.
  • A Text label takes the free room of a wider chip, keeping what follows it at the end.
  • A label written as plain text is not cut short, and overflows a chip too narrow for it.
Within 25 kilometers of the city center
Any price
import { Chip, ChipGroup, Icon } from '@material-web/react'
import { Text } from 'react-aria-components'

export default function LongLabel() {
  return (
    <div className="w-64">
      <ChipGroup aria-label="Filters">
        <Chip id="distance" variant="filter" textValue="Within 25 kilometers of the city center">
          <Text slot="label">Within 25 kilometers of the city center</Text>
          <Icon slot="trailing" name="arrow_drop_down" />
        </Chip>
        <Chip id="price" variant="filter" textValue="Any price" className="w-full">
          <Text slot="label">Any price</Text>
          <Icon slot="trailing" name="arrow_drop_down" />
        </Chip>
      </ChipGroup>
    </div>
  )
}

Give a chip an href to make it a link, with target and rel as on an <a>. A press follows the link, and does not select the chip. The chip is not rendered as an <a> element.

Overview
Specs
Guidelines
import { Chip, ChipGroup, Icon } from '@material-web/react'

const pages = ['Overview', 'Specs', 'Guidelines']

export default function LinkChips() {
  return (
    <ChipGroup aria-label="Material Design pages on chips">
      {pages.map((page) => (
        <Chip
          key={page}
          id={page}
          variant="assist"
          textValue={page}
          href={`https://m3.material.io/components/chips/${page.toLowerCase()}`}
          target="_blank"
          rel="noreferrer"
        >
          <Icon slot="leading" name="open_in_new" />
          {page}
        </Chip>
      ))}
    </ChipGroup>
  )
}

To send these links through a client-side router, wrap the app in RouterProvider from react-aria-components. See Routing.

Customization

Pass classes in className to restyle one chip. A class of yours replaces the chip's own class for the same property. See Styling for the classes, the states and the theme.

Small
Medium
Large
import { Chip, ChipGroup, Icon } from '@material-web/react'

const sizes = ['Small', 'Medium', 'Large']

export default function Custom() {
  return (
    <ChipGroup
      aria-label="Size"
      selectionMode="single"
      defaultSelectedKeys={['medium']}
      className="density-2"
    >
      {sizes.map((size) => (
        <Chip
          key={size}
          id={size.toLowerCase()}
          variant="filter"
          textValue={size}
          className="rounded-shape-full"
        >
          {({ isSelected }) => (
            <>
              {isSelected && <Icon slot="leading" name="check" />}
              {size}
            </>
          )}
        </Chip>
      ))}
    </ChipGroup>
  )
}
  • Density: Add density-1, density-2 or density-3 to the group, or to an element around it. Each step makes its chips 4dp shorter than their 32dp, and their targets stay 48dp. Set it on the group and not on one chip: the chips of a row are as tall as the tallest one. See Density.
  • States: Style a state with its variant, such as hover:, pressed: or selected:. See States.
  • Every chip: To restyle all the chips at once, change the theme.

Children as a function

Pass a function as children to render a chip from its state: isHovered, isPressed, isFocused, isFocusVisible, isSelected, isDisabled, allowsRemoving, selectionMode and selectionBehavior. The function can fill the chip's slots too, as the checkmark of a filter chip does above. The function must be the only child. To return several children, wrap them in a fragment. See Children as a function.

Note: isHovered is reported only for a chip that selects or acts. For a chip with a remove button, it is reported while the pointer is anywhere on the chip, including that button.

className and style can be functions of the same state. The state's type is exported as ChipRenderProps. On a ChipGroup with items, the children are a function that returns a chip for each item.