Key rules
chatty-chipkhai báo 4 attribute, 0 property không có attribute, 2 event, 2 slot, 3 part và 3 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/chip.jslà definechatty-chip; chunk chỉ import element nó dùng. Prototype chuẩn: trong guide. - Đổi tên attribute, event, slot, part hay CSS custom property là đổi API: diff của custom-elements.json phải có trong 1 MR.
On this page
Overview
A compact value pill (an active filter); removable chips add a remove button. Class ChattyChip.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
variant |
variant |
'secondary' | 'tertiary' |
'tertiary' |
tertiary = outlined (default, suggestions and filters); secondary = filled, the selected look. |
size |
size |
'sm' | 'md' |
'md' |
sm is the admin 20px tag; md is the storefront chip. |
removable |
removable |
boolean |
false |
Adds a remove button that fires chatty- |
remove- |
removeLabel |
string |
'Remove' |
Accessible name of the remove button. |
Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
Events
| Name | Detail type | Description |
|---|---|---|
chatty- |
CustomEvent<void> |
The remove button was activated; the host removes the chip. |
click |
MouseEvent |
Native click, retargeted to the host; the remove button also fires chatty- |
Slots
| Name | Description |
|---|---|
| default | Chip text. |
remove- |
Replaces the default × glyph of the remove button. |
Parts
| Name | Description |
|---|---|
base |
Pill box. |
label |
Text wrapper. |
remove |
Native remove button. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Background scoped by variant (secondary = filled, the selected look). |
- |
– | Text colour. |
- |
– | Corner radius. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/chip.js';
<chatty-chip>Shipping</chatty-chip>
<chatty-chip>Returns</chatty-chip>
<chatty-chip variant="secondary">Selected</chatty-chip>
<chatty-chip size="sm">Orders</chatty-chip>
<chatty-chip removable remove-label="Remove filter Website">Website</chatty-chip>
Live preview
Component thật dùng cùng story với trang component; dữ liệu mẫu nằm trong frame cục bộ.
Default: trạng thái mặc định và nội dung mẫu của element.
Show code
<chatty-chip>Shipping</chatty-chip>
<chatty-chip>Returns</chatty-chip>
<chatty-chip variant="secondary">Selected</chatty-chip>
<chatty-chip size="sm">Orders</chatty-chip>
<chatty-chip removable remove-label="Remove filter Website">Website</chatty-chip>Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
Show code
<chatty-chip size="sm" removable remove-label="Remove filter PDF">PDF</chatty-chip>
<chatty-chip size="sm" removable remove-label="Remove filter Website">Website</chatty-chip>
<chatty-chip size="sm" variant="secondary" removable remove-label="Remove filter Covered">Covered</chatty-chip>Anatomy
Số trong hình khớp bảng bên dưới. Phần chỉ hiện ở state khác được ghi Not shown; ví dụ không thêm phần tử giả.
Anatomy: một instance mặc định riêng, có khoảng trống quanh các phần được đánh số.
Show code
<chatty-chip>Shipping</chatty-chip>
<chatty-chip>Returns</chatty-chip>
<chatty-chip variant="secondary">Selected</chatty-chip>
<chatty-chip size="sm">Orders</chatty-chip>
<chatty-chip removable remove-label="Remove filter Website">Website</chatty-chip>| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part label |
chatty- |
| 3 | CSS part remove |
chatty- |
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Activate the remove button when removable. |
Source
- chatty-ui/custom-elements.json