1e41f4b71Sopenharmony_ci# Chip
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe chip component is typically used in the search box history or email address list.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> This component is supported since API version 11. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Child Components
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciNot supported
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Chip
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciChip({options:ChipOptions})
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci**Decorator**: @Builder
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**Parameters**
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci| Name   | Type                       | Mandatory| Decorator| Description                |
26e41f4b71Sopenharmony_ci| ------- | --------------------------- | ---- | ---------- | -------------------- |
27e41f4b71Sopenharmony_ci| options | [ChipOptions](#chipoptions) | Yes  | @Builder   | Parameters of the chip.|
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## ChipOptions
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciDefines the type and style parameters of the chip.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci| Name           | Type                                                        | Mandatory| Description                                                        |
38e41f4b71Sopenharmony_ci| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
39e41f4b71Sopenharmony_ci| size            | [ChipSize](#chipsize) \| [SizeOptions](ts-types.md#sizeoptions) | No  | Size of the chip.<br>Default value: **ChipSize**: **ChipSize.NORMAL**<br>   If of the SizeOptions type, this parameter cannot be set in percentage.|
40e41f4b71Sopenharmony_ci| enabled         | boolean                                                      | No  | Whether the chip can be selected.<br>Default value: **true**|
41e41f4b71Sopenharmony_ci| activated<sup>12+</sup>       | boolean                                        | No  | Whether the chip is activated.<br>Default value: **false**                     |
42e41f4b71Sopenharmony_ci| prefixIcon      | [PrefixIconOptions](#prefixiconoptions)                      | No  | Prefix icon of the chip.|
43e41f4b71Sopenharmony_ci| prefixSymbol<sup>12+</sup>    | [ChipSymbolGlyphOptions](#chipsymbolglyphoptions12)              | No  | Symbol-type prefix icon of the chip.|
44e41f4b71Sopenharmony_ci| label           | [LabelOptions](#labeloptions)                                | Yes  | Text of the chip.  |
45e41f4b71Sopenharmony_ci| suffixIcon      | [SuffixIconOptions](#suffixiconoptions)                      | No  | Suffix icon of the chip.|
46e41f4b71Sopenharmony_ci| suffixSymbol<sup>12+</sup>    | [ChipSymbolGlyphOptions](#chipsymbolglyphoptions12)              | No  | Symbol-type suffix icon of the chip.|
47e41f4b71Sopenharmony_ci| backgroundColor | [ResourceColor](ts-types.md#resourcecolor)                   | No  | Background color of the chip.<br>Default value: **$r('sys.color.ohos_id_color_button_normal').**|
48e41f4b71Sopenharmony_ci| activatedBackgroundColor<sup>12+</sup> | [ResourceColor](ts-types.md#resourcecolor)          | No  | Background color of the chip when it is activated.<br>Default value: **$r('sys.color.ohos_id_color_emphasize').**|
49e41f4b71Sopenharmony_ci| borderRadius    | [Dimension](ts-types.md#dimension10)                         | No  | Border radius of the chip. This parameter cannot be set in percentage.<br>Default value: **$r('sys.float.ohos_id_corner_radius_button')**|
50e41f4b71Sopenharmony_ci| allowClose      | boolean                                                      | No  | Whether to show the close icon.<br>Default value: **true** |
51e41f4b71Sopenharmony_ci| onClose         | ()=>void                                                     | No  | Event triggered when the close icon is clicked.|
52e41f4b71Sopenharmony_ci| onClicked<sup>12+</sup>       | ()=>void                                       | No  | Event triggered when the chip is clicked.                                      |
53e41f4b71Sopenharmony_ci| direction<sup>12+</sup> | [Direction](ts-appendix-enums.md#direction) | No| Layout direction.<br>Default value: **Direction.Auto**|
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci> **NOTE**
56e41f4b71Sopenharmony_ci>
57e41f4b71Sopenharmony_ci> 1. When **suffixSymbol** is provided with an argument, **suffixIcon** and **allowClose** will not take effect. If **suffixSymbol** is not provided, but **suffixIcon** is, **allowClose** still will not take effect. When neither **suffixSymbol** nor **suffixIcon** is provided with arguments, **allowClose** determines whether the deletion icon is displayed.
58e41f4b71Sopenharmony_ci>
59e41f4b71Sopenharmony_ci> 2. If **undefined** is assigned to **backgroundColor** or **activatedBackgroundColor**, the default background color is used. If an invalid value is specified, the background color is transparent.
60e41f4b71Sopenharmony_ci>
61e41f4b71Sopenharmony_ci> 3. Default font colors for **prefixSymbol** and **suffixSymbol**: **normalFontColor**: **[$r('sys.color.ohos_id_color_primary')]**; **activatedFontColor**: **[$r('sys.color.ohos_id_color_text_primary_contrary')]**. The default value of **fontColor** is **16**.
62e41f4b71Sopenharmony_ci>
63e41f4b71Sopenharmony_ci> 4. The default value of **fillColor** is **$r('sys.color.ohos_id_color_secondary')** for **prefixIcon** and **$r('sys.color.ohos_id_color_primary')** for **suffixIcon**. The color parsing of **fillColor** is the same as that of the **\<Image>** component.
64e41f4b71Sopenharmony_ci>
65e41f4b71Sopenharmony_ci> 5. The default value of **activatedFillColor** is **$r('sys.color.ohos_id_color_text_primary_contrary')** for **prefixIcon** and **$r('sys.color.ohos_id_color_text_primary_contrary')** for **suffixIcon**. The color parsing of **activatedFillColor** is the same as that of the **\<Image>** component.
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci## ChipSize
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ciDefines the size type of the chip.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci| Name  | Value      | Description              |
76e41f4b71Sopenharmony_ci| ------ | -------- | ------------------ |
77e41f4b71Sopenharmony_ci| NORMAL | "NORMAL" | Normal size.|
78e41f4b71Sopenharmony_ci| SMALL  | "SMALL"  | Small size. |
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci## IconCommonOptions
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ciDefines the common icon attributes of the chip.
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci| Name     | Type                                      | Mandatory| Description                                                        |
89e41f4b71Sopenharmony_ci| --------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
90e41f4b71Sopenharmony_ci| src       | [ResourceStr](ts-types.md#resourcestr)     | Yes  | Icon source, which can be a specific image path or an image reference.|
91e41f4b71Sopenharmony_ci| size      | [SizeOptions](ts-types.md#sizeoptions)     | No  | Icon size. This parameter cannot be set in percentage.<br>Default value: **{width: 16,height: 16}**|
92e41f4b71Sopenharmony_ci| fillColor | [ResourceColor](ts-types.md#resourcecolor) | No  | Icon fill color.|
93e41f4b71Sopenharmony_ci| activatedFillColor<sup>12+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No  | Icon fill color when the chip is activated.                           |
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci> **NOTE**
96e41f4b71Sopenharmony_ci>
97e41f4b71Sopenharmony_ci> **fillColor** and **activatedFillColor** take effect only when the icon format is SVG.
98e41f4b71Sopenharmony_ci>
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci## PrefixIconOptions
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ciDefines the attributes of the prefix icon.
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ciInherits from [IconCommonOptions](#iconcommonoptions).
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci## SuffixIconOptions
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ciDefines the attributes of the suffix icon.
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ciInherits from [IconCommonOptions](#iconcommonoptions).
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci| Name  | Type      | Mandatory| Description              |
121e41f4b71Sopenharmony_ci| ------ | ---------- | ---- | ------------------ |
122e41f4b71Sopenharmony_ci| action | () => void | No  | Action of the suffix icon.|
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci## ChipSymbolGlyphOptions<sup>12+</sup>
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ciDefines the options for prefix and suffix icons.
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci| Name  | Type      | Mandatory| Description              |
133e41f4b71Sopenharmony_ci| ------ | ---------- | ---- | ------------------ |
134e41f4b71Sopenharmony_ci| normal | [SymbolGlyphModifier](ts-universal-attributes-attribute-modifier.md) | No  | Icon setup event.|
135e41f4b71Sopenharmony_ci| activated | [SymbolGlyphModifier](ts-universal-attributes-attribute-modifier.md) | No  | Icon setup event when the icon is activated.|
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci> **NOTE**
138e41f4b71Sopenharmony_ci>
139e41f4b71Sopenharmony_ci> Modifying the animation type with **symbolEffect** and setting the animation with **effectStrategy** are not supported.
140e41f4b71Sopenharmony_ci>
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci## LabelOptions
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ciDefines the text attributes of the chip.
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci| Name       | Type                                      | Mandatory| Description                                                        |
151e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
152e41f4b71Sopenharmony_ci| text        | string                                     | Yes  | Text content.|
153e41f4b71Sopenharmony_ci| fontSize    | [Dimension](ts-types.md#dimension10)       | No  | Font size. This parameter cannot be set in percentage.<br>Default value: **$r('sys.float.ohos_id_text_size_button2')**|
154e41f4b71Sopenharmony_ci| fontColor   | [ResourceColor](ts-types.md#resourcecolor) | No  | Font color.<br>Default value: **$r('sys.color.ohos_id_color_text_primary')**|
155e41f4b71Sopenharmony_ci| activatedFontColor<sup>12+</sup>   | [ResourceColor](ts-types.md#resourcecolor) | No  | Font color when the chip is activated.<br>Default value: **$r('sys.color.ohos_id_color_text_primary_contrary').**|
156e41f4b71Sopenharmony_ci| fontFamily  | string                                     | No  | Font family.<br>Default value: **"HarmonyOS Sans"**|
157e41f4b71Sopenharmony_ci| labelMargin | [LabelMarginOptions](#labelmarginoptions)  | No  | Spacing between the text and the left and right icons.|
158e41f4b71Sopenharmony_ci| localizedLabelMargin<sup>12+</sup> | [LocalizedLabelMarginOptions](#localizedlabelmarginoptions12) | No| Spacing between the localized text and the left and right icons.<br>Default value: {<br>start:  LengthMetrics.vp(6), end: LengthMetrics.vp(6)<br>} |
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci## LabelMarginOptions
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ciDefines the spacing between the text and the left and right icons.
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci| Name | Type                                | Mandatory| Description                                  |
169e41f4b71Sopenharmony_ci| ----- | ------------------------------------ | ---- | -------------------------------------- |
170e41f4b71Sopenharmony_ci| left  | [Dimension](ts-types.md#dimension10) | No  | Spacing between the text and the left icon. This parameter cannot be set in percentage.|
171e41f4b71Sopenharmony_ci| right | [Dimension](ts-types.md#dimension10) | No  | Spacing between the text and the right icon. This parameter cannot be set in percentage.|
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci## LocalizedLabelMarginOptions<sup>12+</sup>
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ciDefines the spacing between the localized text and the left and right icons.
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci| Name | Type                                                        | Mandatory| Description                                  |
182e41f4b71Sopenharmony_ci| ----- | ------------------------------------------------------------ | ---- | -------------------------------------- |
183e41f4b71Sopenharmony_ci| start | [LengthMetrics](../js-apis-arkui-graphics.md#lengthmetrics12) | No  | Spacing between the text and the left icon. This parameter cannot be set in percentage.|
184e41f4b71Sopenharmony_ci| end   | [LengthMetrics](../js-apis-arkui-graphics.md#lengthmetrics12) | No  | Spacing between the text and the right icon. This parameter cannot be set in percentage.|
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci## Example
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci### Example 1
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ciThis example defines a custom chip for the deletion icon.
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci```ts
193e41f4b71Sopenharmony_ciimport { Chip, ChipSize } from '@kit.ArkUI';
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci@Entry
196e41f4b71Sopenharmony_ci@Component
197e41f4b71Sopenharmony_cistruct Index {
198e41f4b71Sopenharmony_ci  build() {
199e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
200e41f4b71Sopenharmony_ci      Chip({
201e41f4b71Sopenharmony_ci        prefixIcon: {
202e41f4b71Sopenharmony_ci          src: $r('app.media.chips'),
203e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
204e41f4b71Sopenharmony_ci          fillColor: Color.Red
205e41f4b71Sopenharmony_ci        },
206e41f4b71Sopenharmony_ci        label: {
207e41f4b71Sopenharmony_ci          text: "Chip",
208e41f4b71Sopenharmony_ci          fontSize: 12,
209e41f4b71Sopenharmony_ci          fontColor: Color.Blue,
210e41f4b71Sopenharmony_ci          fontFamily: "HarmonyOS Sans",
211e41f4b71Sopenharmony_ci          labelMargin: { left: 20, right: 30 }
212e41f4b71Sopenharmony_ci        },
213e41f4b71Sopenharmony_ci        suffixIcon: {
214e41f4b71Sopenharmony_ci          src: $r('app.media.close'),
215e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
216e41f4b71Sopenharmony_ci          fillColor: Color.Red
217e41f4b71Sopenharmony_ci        },
218e41f4b71Sopenharmony_ci        size: ChipSize.NORMAL,
219e41f4b71Sopenharmony_ci        allowClose: false,
220e41f4b71Sopenharmony_ci        enabled: true,
221e41f4b71Sopenharmony_ci        backgroundColor: $r('sys.color.ohos_id_color_button_normal'),
222e41f4b71Sopenharmony_ci        borderRadius: $r('sys.float.ohos_id_corner_radius_button')
223e41f4b71Sopenharmony_ci      })
224e41f4b71Sopenharmony_ci    }
225e41f4b71Sopenharmony_ci  }
226e41f4b71Sopenharmony_ci}
227e41f4b71Sopenharmony_ci```
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci![](figures/chip1.png)
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci### Example 2
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ciThis example implements the default chip for the deletion icon.
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci```ts
237e41f4b71Sopenharmony_ciimport { Chip, ChipSize } from '@kit.ArkUI';
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci@Entry
240e41f4b71Sopenharmony_ci@Component
241e41f4b71Sopenharmony_cistruct Index {
242e41f4b71Sopenharmony_ci  build() {
243e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
244e41f4b71Sopenharmony_ci      Chip({
245e41f4b71Sopenharmony_ci        prefixIcon: {
246e41f4b71Sopenharmony_ci          src: $r('app.media.chips'),
247e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
248e41f4b71Sopenharmony_ci          fillColor: Color.Blue
249e41f4b71Sopenharmony_ci        },
250e41f4b71Sopenharmony_ci        label: {
251e41f4b71Sopenharmony_ci          text: "Chip",
252e41f4b71Sopenharmony_ci          fontSize: 12,
253e41f4b71Sopenharmony_ci          fontColor: Color.Blue,
254e41f4b71Sopenharmony_ci          fontFamily: "HarmonyOS Sans",
255e41f4b71Sopenharmony_ci          labelMargin: { left: 20, right: 30 }
256e41f4b71Sopenharmony_ci        },
257e41f4b71Sopenharmony_ci        size: ChipSize.NORMAL,
258e41f4b71Sopenharmony_ci        allowClose: true,
259e41f4b71Sopenharmony_ci        enabled: true,
260e41f4b71Sopenharmony_ci        backgroundColor: $r('sys.color.ohos_id_color_button_normal'),
261e41f4b71Sopenharmony_ci        borderRadius: $r('sys.float.ohos_id_corner_radius_button')
262e41f4b71Sopenharmony_ci      })
263e41f4b71Sopenharmony_ci    }
264e41f4b71Sopenharmony_ci  }
265e41f4b71Sopenharmony_ci}
266e41f4b71Sopenharmony_ci```
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci![](figures/chip2.png)
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci### Example 3
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ciThis example shows how to hide the chip for the deletion icon.
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci```ts
276e41f4b71Sopenharmony_ciimport { Chip, ChipSize } from '@kit.ArkUI';
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci@Entry
279e41f4b71Sopenharmony_ci@Component
280e41f4b71Sopenharmony_cistruct Index {
281e41f4b71Sopenharmony_ci  build() {
282e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
283e41f4b71Sopenharmony_ci      Chip({
284e41f4b71Sopenharmony_ci        prefixIcon: {
285e41f4b71Sopenharmony_ci          src: $r('app.media.chips'),
286e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
287e41f4b71Sopenharmony_ci          fillColor: Color.Blue
288e41f4b71Sopenharmony_ci        },
289e41f4b71Sopenharmony_ci        label: {
290e41f4b71Sopenharmony_ci          text: "Chip",
291e41f4b71Sopenharmony_ci          fontSize: 12,
292e41f4b71Sopenharmony_ci          fontColor: Color.Blue,
293e41f4b71Sopenharmony_ci          fontFamily: "HarmonyOS Sans",
294e41f4b71Sopenharmony_ci          labelMargin: { left: 20, right: 30 }
295e41f4b71Sopenharmony_ci        },
296e41f4b71Sopenharmony_ci        size: ChipSize.SMALL,
297e41f4b71Sopenharmony_ci        allowClose: false,
298e41f4b71Sopenharmony_ci        enabled: true,
299e41f4b71Sopenharmony_ci        backgroundColor: $r('sys.color.ohos_id_color_button_normal'),
300e41f4b71Sopenharmony_ci        borderRadius: $r('sys.float.ohos_id_corner_radius_button'),
301e41f4b71Sopenharmony_ci        onClose:()=>{
302e41f4b71Sopenharmony_ci          console.log("chip on close")
303e41f4b71Sopenharmony_ci      }
304e41f4b71Sopenharmony_ci      })
305e41f4b71Sopenharmony_ci    }
306e41f4b71Sopenharmony_ci  }
307e41f4b71Sopenharmony_ci}
308e41f4b71Sopenharmony_ci```
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci![](figures/chip3.png)
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci### Example 4
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ciThis example implements a chip in the activated state.
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci```ts
318e41f4b71Sopenharmony_ciimport { Chip, ChipSize } from '@kit.ArkUI';
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci@Entry
321e41f4b71Sopenharmony_ci@Component
322e41f4b71Sopenharmony_cistruct Index {
323e41f4b71Sopenharmony_ci  @State isActivated: boolean = false
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci  build() {
326e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
327e41f4b71Sopenharmony_ci      Chip({
328e41f4b71Sopenharmony_ci        prefixIcon: {
329e41f4b71Sopenharmony_ci          src: $r('app.media.chips'),
330e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
331e41f4b71Sopenharmony_ci          fillColor: Color.Blue,
332e41f4b71Sopenharmony_ci          activatedFillColor: $r('sys.color.ohos_id_color_text_primary_contrary')
333e41f4b71Sopenharmony_ci        },
334e41f4b71Sopenharmony_ci        label: {
335e41f4b71Sopenharmony_ci          text: "Chip",
336e41f4b71Sopenharmony_ci          fontSize: 12,
337e41f4b71Sopenharmony_ci          fontColor: Color.Blue,
338e41f4b71Sopenharmony_ci          activatedFontColor: $r('sys.color.ohos_id_color_text_primary_contrary'),
339e41f4b71Sopenharmony_ci          fontFamily: "HarmonyOS Sans",
340e41f4b71Sopenharmony_ci          labelMargin: { left: 20, right: 30 }
341e41f4b71Sopenharmony_ci        },
342e41f4b71Sopenharmony_ci        size: ChipSize.NORMAL,
343e41f4b71Sopenharmony_ci        allowClose: true,
344e41f4b71Sopenharmony_ci        enabled: true,
345e41f4b71Sopenharmony_ci        activated: this.isActivated,
346e41f4b71Sopenharmony_ci        backgroundColor: $r('sys.color.ohos_id_color_button_normal'),
347e41f4b71Sopenharmony_ci        activatedBackgroundColor: $r('sys.color.ohos_id_color_emphasize'),
348e41f4b71Sopenharmony_ci        borderRadius: $r('sys.float.ohos_id_corner_radius_button'),
349e41f4b71Sopenharmony_ci        onClose:()=>{
350e41f4b71Sopenharmony_ci          console.log("chip on close")
351e41f4b71Sopenharmony_ci        },
352e41f4b71Sopenharmony_ci        onClicked:()=>{
353e41f4b71Sopenharmony_ci          console.log("chip on clicked")
354e41f4b71Sopenharmony_ci        }
355e41f4b71Sopenharmony_ci      })
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci      Button('Activate/Deactivate').onClick(()=>{
358e41f4b71Sopenharmony_ci        this.isActivated = !this.isActivated
359e41f4b71Sopenharmony_ci      })
360e41f4b71Sopenharmony_ci    }
361e41f4b71Sopenharmony_ci  }
362e41f4b71Sopenharmony_ci}
363e41f4b71Sopenharmony_ci```
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci![](figures/chip4.gif)
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci### Example 5
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ciThis example implements symbol-type prefix and suffix icons for the **Chip** component.
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci```ts
373e41f4b71Sopenharmony_ciimport { Chip, ChipSize, SymbolGlyphModifier } from '@kit.ArkUI';
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci@Entry
376e41f4b71Sopenharmony_ci@Component
377e41f4b71Sopenharmony_cistruct Index {
378e41f4b71Sopenharmony_ci  @State isActivated: boolean = false
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci  build() {
381e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
382e41f4b71Sopenharmony_ci      Chip({
383e41f4b71Sopenharmony_ci        prefixIcon: {
384e41f4b71Sopenharmony_ci          src: $r('app.media.chips'),
385e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
386e41f4b71Sopenharmony_ci          fillColor: Color.Blue,
387e41f4b71Sopenharmony_ci          activatedFillColor: $r('sys.color.ohos_id_color_text_primary_contrary')
388e41f4b71Sopenharmony_ci        },
389e41f4b71Sopenharmony_ci		prefixSymbol: {
390e41f4b71Sopenharmony_ci          normal: new SymbolGlyphModifier($r('sys.symbol.ohos_star')).fontSize(16).fontColor([Color.Green]),
391e41f4b71Sopenharmony_ci          activated: new SymbolGlyphModifier($r('sys.symbol.ohos_star')).fontSize(16).fontColor([Color.Red]),
392e41f4b71Sopenharmony_ci		},
393e41f4b71Sopenharmony_ci        label: {
394e41f4b71Sopenharmony_ci          text: "Chip",
395e41f4b71Sopenharmony_ci          fontSize: 12,
396e41f4b71Sopenharmony_ci          fontColor: Color.Blue,
397e41f4b71Sopenharmony_ci          activatedFontColor: $r('sys.color.ohos_id_color_text_primary_contrary'),
398e41f4b71Sopenharmony_ci          fontFamily: "HarmonyOS Sans",
399e41f4b71Sopenharmony_ci          labelMargin: { left: 20, right: 30 },
400e41f4b71Sopenharmony_ci        },
401e41f4b71Sopenharmony_ci        size: ChipSize.NORMAL,
402e41f4b71Sopenharmony_ci        allowClose: true,
403e41f4b71Sopenharmony_ci        enabled: true,
404e41f4b71Sopenharmony_ci        activated: this.isActivated,
405e41f4b71Sopenharmony_ci        backgroundColor: $r('sys.color.ohos_id_color_button_normal'),
406e41f4b71Sopenharmony_ci        activatedBackgroundColor: $r('sys.color.ohos_id_color_emphasize'),
407e41f4b71Sopenharmony_ci        borderRadius: $r('sys.float.ohos_id_corner_radius_button'),
408e41f4b71Sopenharmony_ci        onClose:()=>{
409e41f4b71Sopenharmony_ci          console.log("chip on close")
410e41f4b71Sopenharmony_ci        },
411e41f4b71Sopenharmony_ci        onClicked:()=>{
412e41f4b71Sopenharmony_ci          console.log("chip on clicked")
413e41f4b71Sopenharmony_ci        }
414e41f4b71Sopenharmony_ci      })
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci      Button('Activate/Deactivate').onClick(()=>{
417e41f4b71Sopenharmony_ci        this.isActivated = !this.isActivated
418e41f4b71Sopenharmony_ci      })
419e41f4b71Sopenharmony_ci    }
420e41f4b71Sopenharmony_ci  }
421e41f4b71Sopenharmony_ci}
422e41f4b71Sopenharmony_ci```
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci![](figures/chip5.gif)
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci### Example 6
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ciThis example mirrors the layout of the **Chip** component.
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci```ts
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ciimport { Chip, ChipSize,LengthMetrics } from '@kit.ArkUI';
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci@Entry
435e41f4b71Sopenharmony_ci@Component
436e41f4b71Sopenharmony_cistruct ChipPage {
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci  build() {
439e41f4b71Sopenharmony_ci    Column() {
440e41f4b71Sopenharmony_ci      Chip({
441e41f4b71Sopenharmony_ci        direction: Direction.Rtl,
442e41f4b71Sopenharmony_ci        prefixIcon: {
443e41f4b71Sopenharmony_ci          src: $r('app.media.chips'),
444e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
445e41f4b71Sopenharmony_ci          fillColor: Color.Red,
446e41f4b71Sopenharmony_ci        },
447e41f4b71Sopenharmony_ci        label: {
448e41f4b71Sopenharmony_ci          text: "Chip",
449e41f4b71Sopenharmony_ci          fontSize: 12,
450e41f4b71Sopenharmony_ci          fontColor: Color.Blue,
451e41f4b71Sopenharmony_ci          fontFamily: "HarmonyOS Sans",
452e41f4b71Sopenharmony_ci          localizedLabelMargin: { start: LengthMetrics.vp(20), end: LengthMetrics.vp(20) },
453e41f4b71Sopenharmony_ci        },
454e41f4b71Sopenharmony_ci        suffixIcon: {
455e41f4b71Sopenharmony_ci          src: $r('app.media.close'),
456e41f4b71Sopenharmony_ci          size: { width: 16, height: 16 },
457e41f4b71Sopenharmony_ci          fillColor: Color.Red,
458e41f4b71Sopenharmony_ci        },
459e41f4b71Sopenharmony_ci        size: ChipSize.NORMAL,
460e41f4b71Sopenharmony_ci        allowClose: false,
461e41f4b71Sopenharmony_ci        enabled: true,
462e41f4b71Sopenharmony_ci        backgroundColor: $r('sys.color.ohos_id_color_button_normal'),
463e41f4b71Sopenharmony_ci        borderRadius: $r('sys.float.ohos_id_corner_radius_button')
464e41f4b71Sopenharmony_ci      })
465e41f4b71Sopenharmony_ci    }.justifyContent(FlexAlign.Center)
466e41f4b71Sopenharmony_ci    .width('100%')
467e41f4b71Sopenharmony_ci    .height('100%')
468e41f4b71Sopenharmony_ci  }
469e41f4b71Sopenharmony_ci}
470e41f4b71Sopenharmony_ci```
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci![](figures/chip6.png)
474