Key rules
chatty-sheetkhai 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.jslà definechatty-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- |
label |
label |
string |
'' |
Accessible name; when empty, the heading slot names the sheet. |
close- |
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- |
CustomEvent<{ |
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 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 |
|---|---|---|
- |
– | 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ộ.
Default: trạng thái mặc định và nội dung mẫu của element.
Show code
<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>Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
Show code
<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ả.
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 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- |
| 2 | CSS part scrim |
chatty- |
| 3 | CSS part header |
chatty- |
| 4 | CSS part close |
chatty- |
| 5 | CSS part body |
chatty- |
Keyboard
| Key | Action |
|---|---|
| Escape | Close the sheet and return focus. |
| Tab / Shift+Tab | Move through the modal controls. |
Source
- chatty-ui/custom-elements.json