1 |
|
2 | title: "Chips"
|
3 | layout: detail
|
4 | section: components
|
5 | excerpt: "Chips are compact elements that represent an attribute, text, entity, or action."
|
6 | iconId: chip
|
7 | path: /catalog/chips/
|
8 | -->
|
9 |
|
10 | # Chips
|
11 |
|
12 | **Contents**
|
13 |
|
14 | * [Using chip](#using-chips)
|
15 | * [Chips](#chips)
|
16 | * [API](#api)
|
17 |
|
18 | >Looking for deprecated chips resources? Visit the [deprecated readme](deprecated/README.md).
|
19 |
|
20 | ## Using chips
|
21 |
|
22 | Chips are compact elements that allow users to enter information, select a choice, filter content, or trigger an action. Chips must always be used inside a chip set.
|
23 |
|
24 | ### Installing chips
|
25 |
|
26 | ```
|
27 | npm install @material/chips
|
28 | ```
|
29 |
|
30 | ### Styles
|
31 |
|
32 | ```scss
|
33 | @use "@material/chips/styles";
|
34 | ```
|
35 |
|
36 | ### JavaScript instantiation
|
37 |
|
38 | **Note**: there's work planned to replace the `mdc-evolution-*` prefix of chips with the standard `mdc-chip-*` prefix.
|
39 |
|
40 | ```js
|
41 | import {MDCChipSet} from '@material/chips';
|
42 | const chipset = new MDCChipSet(document.querySelector('.mdc-evolution-chip-set'));
|
43 | ```
|
44 |
|
45 | ## Chips
|
46 |
|
47 | Chips are comprised of [chip sets](./chip-set) which are comprised of [chip](./chip) instances which are in turn comprised of [actions](./action). See the readme for each subcomponent for more detail.
|
48 |
|
49 | ### Basic action chip set example
|
50 |
|
51 | ```html
|
52 | <span class="mdc-evolution-chip-set" role="grid">
|
53 | <span class="mdc-evolution-chip-set__chips" role="presentation">
|
54 | <span class="mdc-evolution-chip" role="row" id="c0">
|
55 | <span class="mdc-evolution-chip__cell mdc-evolution-chip__cell--primary" role="gridcell">
|
56 | <button class="mdc-evolution-chip__action mdc-evolution-chip__action--primary" type="button" tabindex="0">
|
57 | <span class="mdc-evolution-chip__ripple mdc-evolution-chip__ripple--primary"></span>
|
58 | <span class="mdc-evolution-chip__text-label">Chip one</span>
|
59 | </button>
|
60 | </span>
|
61 | </span>
|
62 | <span class="mdc-evolution-chip" role="row" id="c1">
|
63 | <span class="mdc-evolution-chip__cell mdc-evolution-chip__cell--primary" role="gridcell">
|
64 | <button class="mdc-evolution-chip__action mdc-evolution-chip__action--primary" type="button" tabindex="-1">
|
65 | <span class="mdc-evolution-chip__ripple mdc-evolution-chip__ripple--primary"></span>
|
66 | <span class="mdc-evolution-chip__text-label">Chip two</span>
|
67 | </button>
|
68 | </span>
|
69 | </span>
|
70 | </span>
|
71 | </span>
|
72 | ```
|
73 |
|
74 | ## API
|
75 |
|
76 | See the readme of each subcomponent for more detail.
|
77 |
|
78 | - [Chip set API](./chip-set#api)
|
79 | - [Chip API](./chip#api)
|
80 | - [Action API](./action#api)
|
81 |
|
82 | ### Usage within frameworks
|
83 |
|
84 | If you are using a JavaScript framework, such as React or Angular, you can create chips for your framework. Depending on your needs, you can use the _Simple Approach: Wrapping MDC Web Vanilla Components_, or the _Advanced Approach: Using Foundations and Adapters_. Please follow the instructions [here](../../../docs/integrating-into-frameworks.md).
|