On this page

chatty-card

API chuẩn của element chatty-card, sinh từ custom-elements.json của prototype trong guide.

Copy page as MarkdownRead Markdown ↗

Key rules

  • chatty-card khai 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.js là define chatty-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
--chatty-card-padding – Inner padding of every row.
--chatty-card-radius – 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ộ.

Standard
LightDarkDesktopMobile

Default: trạng thái mặc định và nội dung mẫu của element.

Show code
chatty-card.element.jsWrap code linesCopy
<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ả.

Standard
LightDarkDesktopMobile

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.element.jsWrap code linesCopy
<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-ui/custom-elements.json
2 CSS part header chatty-ui/custom-elements.json
3 CSS part body chatty-ui/custom-elements.json
4 CSS part footer chatty-ui/custom-elements.json

Keyboard

No element-specific keys.

Source

  • chatty-ui/custom-elements.json