On this page Key rules Overview Usage Live preview Anatomy Keyboard Element API
chatty-popover API chuẩn của element chatty-popover, sinh từ custom-elements.json của prototype trong guide.
Copy page as Markdown Read Markdown ↗ Key rules
chatty-popover khai báo 3 attribute, 1 property không có attribute, 1 event, 2 slot, 1 part và 2 CSS custom property.
Import 1 module @avada/chatty-ui/elements/popover.js là define chatty-popover; 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 Key rules Overview Attributes Properties Events Slots Parts CSS custom properties Usage Live preview Anatomy Keyboard Source Overview
A floating panel anchored to the trigger in the trigger slot, drawn in the top layer so a clipping ancestor (the glass composer dock) never cuts it. The trigger toggles it; Escape closes it and returns focus to the trigger; a pointer press outside closes it. Class ChattyPopover.
Attributes
Properties
Attributes also expose the properties listed in the Property column above.
Name
Type
Default
Description
panelRole
'dialog' | 'menu'
'dialog'
ARIA role of the panel; aria-haspopup on the trigger follows it.
Events
Name
Detail type
Description
toggle
ToggleEvent
The panel opened or closed; newState is open or closed.
Slots
Name
Description
default
Panel content.
trigger
The control that opens the panel; it receives aria-haspopup and aria-expanded .
Parts
Name
Description
base
The top-layer panel.
CSS custom properties
Name
Default
Description
--chatty-popover-min-width
–
Minimum panel width.
--chatty-popover-padding
–
Panel padding.
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import {IconSmile} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-popover prototype chatty-ui ports from (chatty-ui/src/elements/popover.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/popover.js';
export function Standard() {
return html`
<chatty-popover open label="Emoji" style="margin-block-end: 180px">
<button
slot="trigger"
type="button"
aria-label="Emoji"
style="display:inline-grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid var(--chatty-color-border);border-radius:999px;background:var(--chatty-color-bg-surface);color:var(--chatty-color-text);cursor:pointer"
>
${IconSmile({size: 16})}
</button>
<div style="display: grid; grid-template-columns: repeat(4, 36px); gap: 4px; font-size: 20px">
<button
type="button"
aria-label="Thumbs up"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
👍
</button>
<button
type="button"
aria-label="Heart"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
❤️
</button>
<button
type="button"
aria-label="Smile"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
😊
</button>
<button
type="button"
aria-label="Party"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
🎉
</button>
</div>
</chatty-popover>
`;
}
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
Surface AI Mode Light Dark Desktop Mobile
Default: trạng thái mặc định và nội dung mẫu của element.
Show code chatty-popover.element.js Wrap code lines Copy import '@avada/chatty-ui/tokens/tokens.css';
import {IconSmile} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-popover prototype chatty-ui ports from (chatty-ui/src/elements/popover.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/popover.js';
export function Standard() {
return html`
<chatty-popover open label="Emoji" style="margin-block-end: 180px">
<button
slot="trigger"
type="button"
aria-label="Emoji"
style="display:inline-grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid var(--chatty-color-border);border-radius:999px;background:var(--chatty-color-bg-surface);color:var(--chatty-color-text);cursor:pointer"
>
${IconSmile({size: 16})}
</button>
<div style="display: grid; grid-template-columns: repeat(4, 36px); gap: 4px; font-size: 20px">
<button
type="button"
aria-label="Thumbs up"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
👍
</button>
<button
type="button"
aria-label="Heart"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
❤️
</button>
<button
type="button"
aria-label="Smile"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
😊
</button>
<button
type="button"
aria-label="Party"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
🎉
</button>
</div>
</chatty-popover>
`;
}
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
Surface AI Mode Light Dark Desktop Mobile
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-popover.element.js Wrap code lines Copy import '@avada/chatty-ui/tokens/tokens.css';
import {IconSmile} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-popover prototype chatty-ui ports from (chatty-ui/src/elements/popover.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/popover.js';
export function Standard() {
return html`
<chatty-popover open label="Emoji" style="margin-block-end: 180px">
<button
slot="trigger"
type="button"
aria-label="Emoji"
style="display:inline-grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid var(--chatty-color-border);border-radius:999px;background:var(--chatty-color-bg-surface);color:var(--chatty-color-text);cursor:pointer"
>
${IconSmile({size: 16})}
</button>
<div style="display: grid; grid-template-columns: repeat(4, 36px); gap: 4px; font-size: 20px">
<button
type="button"
aria-label="Thumbs up"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
👍
</button>
<button
type="button"
aria-label="Heart"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
❤️
</button>
<button
type="button"
aria-label="Smile"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
😊
</button>
<button
type="button"
aria-label="Party"
style="height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer"
>
🎉
</button>
</div>
</chatty-popover>
`;
}
Part
Element
Source
1
CSS part base
chatty-ui/custom-elements.json
Keyboard
Key
Action
Enter / Space
Activate the trigger.
Escape
Dismiss and return focus to the trigger.
Source
chatty-ui/custom-elements.json
Chatty UI · Chrome dùng chatty-ui theo palette light/dark của guide; specimen giữ surface riêng. Surface dùng native select để bốn nhãn vẫn vừa ở 390px.