Pular para o conteúdo

Chip

Chips são elementos compactos que representam uma entrada, atributo ou ação.

Chips permitirão que usuários insiram informações, façam seleções, filtrem conteúdo ou acionem gatilhos.

Embora incluído aqui como um componente independente, o uso mais comum será em alguma forma de entrada, portanto, alguns dos comportamentos demonstrados aqui não são mostrados considerando um contexto.

Basic chip

The Chip component supports outlined and filled styling.

Chip Filled
Chip Outlined
<Chip label="Chip Filled" />
<Chip label="Chip Outlined" variant="outlined" />

Chip actions

You can use the following actions.

  • Chips with the onClick prop defined change appearance on focus, hover, and click.
  • Chips with the onDelete prop defined will display a delete icon which changes appearance on hover.

Clickeable

Clickable
Clickable
<Chip label="Clickable" onClick={handleClick} />
<Chip label="Clickable" variant="outlined" onClick={handleClick} />

Deleteable

Deletable
Deletable
<Chip label="Deletable" onDelete={handleDelete} />
<Chip label="Deletable" variant="outlined" onDelete={handleDelete} />

Clickeable and deleteable

Clickable Deletable
Clickable Deletable
<Chip
  label="Clickable Deletable"
  onClick={handleClick}
  onDelete={handleDelete}
/>
<Chip
  label="Clickable Deletable"
  variant="outlined"
  onClick={handleClick}
  onDelete={handleDelete}
/>
<Chip label="Clickable Link" component="a" href="#basic-chip" clickable />
<Chip
  label="Clickable Link"
  component="a"
  href="#basic-chip"
  variant="outlined"
  clickable
/>

Custom delete icon

Custom delete icon
Custom delete icon
<Chip
  label="Custom delete icon"
  onClick={handleClick}
  onDelete={handleDelete}
  deleteIcon={<DoneIcon />}
/>
<Chip
  label="Custom delete icon"
  onClick={handleClick}
  onDelete={handleDelete}
  deleteIcon={<DeleteIcon />}
  variant="outlined"
/>

Chip adornments

You can add ornaments to the beginning of the component.

Use the avatar prop to added a avatar or use the icon prop to added a icon.

Avatar chip

M
Avatar
Natacha
Avatar
<Chip avatar={<Avatar>M</Avatar>} label="Avatar" />
<Chip
  avatar={<Avatar alt="Natacha" src="/static/images/avatar/1.jpg" />}
  label="Avatar"
  variant="outlined"
/>

Icon chip

With Icon
With Icon
<Chip icon={<FaceIcon />} label="With Icon" />
<Chip icon={<FaceIcon />} label="With Icon" variant="outlined" />

Color chip

You can use the color prop to define a primary or secondary color.

primary
success
primary
success
<Stack direction="row" spacing={1}>
  <Chip label="primary" color="primary" />
  <Chip label="success" color="success" />
</Stack>
<Stack direction="row" spacing={1}>
  <Chip label="primary" color="primary" variant="outlined" />
  <Chip label="success" color="success" variant="outlined" />
</Stack>

Sizes chip

Você pode usar a propriedade size para definir um Chip pequeno.

Small
Small
<Chip label="Small" size="small" />
<Chip label="Small" size="small" variant="outlined" />

Matriz de Chip (Array)

An example of rendering multiple chips from an array of values. Deletando um chip irá remove-lo da matriz. Note that since no onClick prop is defined, the Chip can be focused, but does not gain depth while clicked or touched.

  • Angular
  • jQuery
  • Polymer
  • React
  • Vue.js

Chip playground

Chip Component
<Chip />

Acessibilidade

Se o Chip é deletável ou clicável, então é como um botão na ordem da tabulação. Quando o Chip está focado (ex. quando tabulando) pressionando (evento keyup) Backspace ou Delete irá chamar o evento manipulador onDelete, enquanto liberando com a tecla Escape irá tirar o foco do Chip.