On this page

chatty-sheet

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

Copy page as MarkdownRead Markdown ↗

Key rules

  • chatty-sheet khai báo 4 attribute, 0 property không có attribute, 2 event, 4 slot, 5 part và 1 CSS custom property.
  • Import 1 module @avada/chatty-ui/elements/sheet.js là define chatty-sheet; 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 side sheet: a right column beside the conversation (layout column) or a slide-over covering the nearest positioned ancestor with a scrim (layout overlay, the mobile widget). The column is non-modal (role complementary): Tab can leave it. The overlay is modal (role dialog, aria-modal) and keeps Tab inside. Opening moves focus to the close button; Escape, the scrim and the close button ask to close through a cancelable chatty-close, and closing returns focus to the opener. A sheet already open when it connects keeps Escape and the trap but does not take focus. Class ChattySheet.

Attributes

Name Property Type Default Description
open open boolean false Shows the sheet; opening moves focus to the close button.
layout layout 'column' | 'overlay' 'column' Column sits beside the content (non-modal); overlay covers it with a scrim (modal).
label label string '' Accessible name; when empty, the heading slot names the sheet.
close-label closeLabel string 'Close' Accessible name of the close button.

Properties

Attributes also expose the properties listed in the Property column above.

Not declared in the manifest.

Events

Name Detail type Description
click MouseEvent Native click of the close button; it bubbles out of the shadow root.
chatty-close CustomEvent<{reason: 'escape' | 'backdrop' | 'close-button'}> A request to close; preventDefault keeps the sheet open.

Slots

Name Description
default Sheet body.
heading Title; names the sheet when label is empty.
actions Header controls before the close button.
close-icon Icon of the close button; a cross by default.

Parts

Name Description
base The sheet panel (role complementary, or dialog in the overlay layout).
scrim Backdrop of the overlay layout.
header Heading row.
close Close button.
body Body wrapper.

CSS custom properties

Name Default Description
--chatty-sheet-width – Column width of the column layout.

Usage

import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/sheet.js';
<chatty-sheet open style="height: 360px; margin-inline-start: auto">
  <span slot="heading">Classic leather boot</span>
  <p style="margin: 0">Full-grain leather, a cushioned insole and a rubber sole. Free returns within 30 days.</p>
</chatty-sheet>

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-sheet.element.jsWrap code linesCopy
<chatty-sheet open style="height: 360px; margin-inline-start: auto">
  <span slot="heading">Classic leather boot</span>
  <p style="margin: 0">Full-grain leather, a cushioned insole and a rubber sole. Free returns within 30 days.</p>
</chatty-sheet>
Standard
LightDarkDesktopMobile

Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.

Show code
chatty-sheet.element.jsWrap code linesCopy
<chatty-sheet open layout="overlay" style="position: relative; width: 340px; height: 420px">
  <span slot="heading">Your bag</span>
  <p style="margin: 0">2 items · $148.00</p>
</chatty-sheet>

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-sheet.element.jsWrap code linesCopy
<chatty-sheet open style="height: 360px; margin-inline-start: auto">
  <span slot="heading">Classic leather boot</span>
  <p style="margin: 0">Full-grain leather, a cushioned insole and a rubber sole. Free returns within 30 days.</p>
</chatty-sheet>
Part Element Source
1 CSS part base chatty-ui/custom-elements.json
2 CSS part scrim chatty-ui/custom-elements.json
3 CSS part header chatty-ui/custom-elements.json
4 CSS part close chatty-ui/custom-elements.json
5 CSS part body chatty-ui/custom-elements.json

Keyboard

Key Action
Escape Close the sheet and return focus.
Tab / Shift+Tab Move through the modal controls.

Source

  • chatty-ui/custom-elements.json