Key rules
chatty-cardkhai báo 0 attribute, 0 property không có attribute, 0 event, 3 slot, 4 part và 2 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/card.jslà definechatty-card; 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 raised surface grouping related content. Header and footer rows collapse when nothing is slotted into them. Not interactive: put a link or button inside for actions. Class ChattyCard.
Attributes
Not declared in the manifest.
Properties
Not declared in the manifest.
Events
Not declared in the manifest.
Slots
| Name | Description |
|---|---|
| default | Card body. |
header |
Title and subtitle row. |
footer |
Actions row. |
Parts
| Name | Description |
|---|---|
base |
Card box. |
header |
Header wrapper. |
body |
Body wrapper. |
footer |
Footer wrapper. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Inner padding of every row. |
- |
– | Corner radius. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/card.js';
import '@avada/chatty-ui/elements/button.js';
<chatty-card style="width: min(360px, 100%)">
<span slot="header">Order #1024</span>
Placed on 12 Nov · 2 items · Shipped
<chatty-button slot="footer" variant="primary">Track order</chatty-button>
<chatty-button slot="footer" variant="tertiary">View details</chatty-button>
</chatty-card>
<chatty-card style="width: min(360px, 100%)">A body-only card: header and footer rows collapse when empty.</chatty-card>
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-card style="width: min(360px, 100%)">
<span slot="header">Order #1024</span>
Placed on 12 Nov · 2 items · Shipped
<chatty-button slot="footer" variant="primary">Track order</chatty-button>
<chatty-button slot="footer" variant="tertiary">View details</chatty-button>
</chatty-card>
<chatty-card style="width: min(360px, 100%)">A body-only card: header and footer rows collapse when empty.</chatty-card>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-card style="width: min(360px, 100%)">
<span slot="header">Order #1024</span>
Placed on 12 Nov · 2 items · Shipped
<chatty-button slot="footer" variant="primary">Track order</chatty-button>
<chatty-button slot="footer" variant="tertiary">View details</chatty-button>
</chatty-card>
<chatty-card style="width: min(360px, 100%)">A body-only card: header and footer rows collapse when empty.</chatty-card>| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part header |
chatty- |
| 3 | CSS part body |
chatty- |
| 4 | CSS part footer |
chatty- |
Keyboard
No element-specific keys.
Source
- chatty-ui/custom-elements.json