Key rules
chatty-launcherkhai báo 6 attribute, 0 property không có attribute, 3 event, 3 slot, 5 part và 2 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/launcher.jslà definechatty-launcher; 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
AI Mode resting launcher: a pill with the assistant orb and an invite line that opens the panel, and an optional bag button that opens the cart. Pointer enter or focus asks the host to preload the panel once. Class ChattyLauncher.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
label |
label |
string |
'' |
Accessible name of the trigger, e.Open Chatty. |
bag |
bag |
boolean |
false |
Show the bag button; a confirmed empty cart removes it. |
count |
count |
number |
0 |
Items in the cart; the badge shows above 0, capped at 99+. |
bag- |
bagLabel |
string |
'Shopping bag' |
Bag button name when the count is 0. |
count- |
countLabel |
string |
'{ |
Bag name when count is above 0; { is replaced. |
live |
live |
boolean |
false |
Show the online dot on the orb. |
Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
Events
| Name | Detail type | Description |
|---|---|---|
chatty- |
CustomEvent<{ |
The trigger or the bag was activated. |
chatty- |
CustomEvent<{ |
First pointer enter or focus; load the panel ahead. |
click |
MouseEvent |
Native activation of the trigger or bag. |
Slots
| Name | Description |
|---|---|
| default | Invite line, e.Ask a question. |
icon |
Assistant icon inside the 40px orb. |
bag- |
Bag icon; shown when bag is set. |
Parts
| Name | Description |
|---|---|
base |
Pill container. |
trigger |
Button that opens the panel. |
orb |
Assistant orb. |
bag |
Bag button. |
count |
Bag count badge. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Pill width. |
- |
– | Pill background. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/launcher.js';
<chatty-launcher label="Open Chatty" live>
<svg slot="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z" />
</svg>
Ask a question
</chatty-launcher>
<chatty-launcher label="Open Chatty" bag count="2">
<svg slot="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z" />
</svg>
Ask a question
<svg
slot="bag-icon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
aria-hidden="true"
>
<path d="M5 8h14l-1 12H6zM9 8a3 3 0 0 1 6 0" />
</svg>
</chatty-launcher>
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-launcher label="Open Chatty" live>
<svg slot="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z" />
</svg>
Ask a question
</chatty-launcher>
<chatty-launcher label="Open Chatty" bag count="2">
<svg slot="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z" />
</svg>
Ask a question
<svg
slot="bag-icon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
aria-hidden="true"
>
<path d="M5 8h14l-1 12H6zM9 8a3 3 0 0 1 6 0" />
</svg>
</chatty-launcher>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-launcher label="Open Chatty" live>
<svg slot="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z" />
</svg>
Ask a question
</chatty-launcher>
<chatty-launcher label="Open Chatty" bag count="2">
<svg slot="icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z" />
</svg>
Ask a question
<svg
slot="bag-icon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
aria-hidden="true"
>
<path d="M5 8h14l-1 12H6zM9 8a3 3 0 0 1 6 0" />
</svg>
</chatty-launcher>| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part trigger |
chatty- |
| 3 | CSS part orb |
chatty- |
| 4 | CSS part bag |
chatty- |
| 5 | CSS part count |
chatty- |
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Activate the launcher or bag action. |
Source
- chatty-ui/custom-elements.json