Key rules
- Classic: action chính trong chat dùng
Button+Avada-Faqs_Primary-ButtonvàSpinnertừ đường import của caller; xem Import / element. - AI Mode: dùng native button với CSS kit; class, kích thước và trạng thái nằm trong bảng AI Mode.
- Admin: Polaris ngoài Inbox; Inbox dùng chatty-ui Target 2.0.
- Admin · Knowledge files: shared
Buttonchịu stylesheet của trang; kích thước đọc ở bảng riêng. - Element
chatty-buttonở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy, Target giữ thay đổi dự kiến.
On this page
Use when / Avoid
Dùng hành động có kết quả rõ ràng. Điều hướng trong nội dung dùng Link; thao tác chỉ có biểu tượng cần tên truy cập. Mỗi surface có owner riêng, không đổi API theo tên nhìn giống nhau.
Use instead
| Component | Use when |
|---|---|
Button |
Action của Classic hoặc Knowledge files; không phải API Polaris. |
a |
Điều hướng khi href có giá trị; disabled native không áp lên anchor. |
button |
AI Mode CSS kit, không import shared Button. |
Button |
Admin gọi Polaris, ví dụ WidgetModeCard dùng tertiary. |
Live preview
Standard
Form transcript có email, Send primary và Cancel secondary; token theo surface. Classic dark: Cancel dùng nền tối; widget đang ship khối trắng.
Show code
import '@avada/chatty-ui/tokens/tokens.css';
// Standard: the chatty-button prototype chatty-ui ports from (chatty-ui/src/elements/button.js).
import {html} from 'lit';
import {IconClose, IconMessage} from '@avada/chatty-ui/elements/icon-glyphs.js';
import '@avada/chatty-ui/elements/surface.js';
import '@avada/chatty-ui/elements/avatar.js';
import '@avada/chatty-ui/elements/badge.js';
import '@avada/chatty-ui/elements/icon-button.js';
import '@avada/chatty-ui/elements/launcher.js';
import '@avada/chatty-ui/elements/button.js';
import {sameGroup} from '@avada/chatty-ui/behaviors/messages.js';
// Reference viewport: 1280 × 900 desktop, 390 × 900 mobile.
const sizes = {
classic: {width: 400, height: 700},
'ai-mode': {width: 820, height: 657},
admin: {width: 527, height: 842}
};
const question = {
id: 'question',
senderType: 'customer',
text: 'Can you help me?',
createdAt: '2026-01-15T10:00:00Z'
};
/** Viewport-relative sizing survives the initial hidden iframe layout. */
function widgetSize(surface) {
const mode = new URLSearchParams(location.search).get('mobile');
const isMobile = mode === null ? innerWidth < 900 : mode === 'true';
const width = `min(${sizes[surface].width}px, max(0px, 100vw - 40px))`;
const height = isMobile
? `min(${surface === 'admin' ? 848 : 888}px, round(down, calc(${width} * 2.2), 1px))`
: `${sizes[surface].height}px`;
return {...sizes[surface], height, mobile: isMobile};
}
/** Local immutable message state with real subscriptions for live previews. */
function fixtureStore(initial) {
let state = {messages: initial};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach(listener => listener());
}
};
}
/** Appends the viewer message without replacing the existing conversation. */
function appendViewer(store, surface, text) {
const message = {
id: `viewer-${store.getState().messages.length}`,
senderType: surface === 'admin' ? 'agent' : 'customer',
senderMeta: {name: surface === 'admin' ? 'Alex' : 'You'},
text,
createdAt: new Date().toISOString()
};
store.setMessages([...store.getState().messages, message]);
}
/**
* One shell owns surface sizing, header, thread and composer for every pattern.
* @param {string} surface
* @param {Object} store
* @param {Object} strings
* @param {Object} content
* @param {Function} renderMessage
* @param {Function} onSend
* @param {Object} registry
* @param {boolean} composerHidden
* @param {string} title
* @param {Object} headerStart
* @param {Object} headerActions
* @param {boolean} sheet
* @param {string | null} status
* @returns {Object}
*/
function patternShell({
surface,
store,
strings = {header: 'Store assistant', message: 'Message', send: 'Send'},
content,
renderMessage,
onSend,
registry,
title,
headerStart,
headerActions,
status = 'online',
sheet = false,
composerHidden = false
}) {
const size = widgetSize(surface);
const mobileSheet = sheet && size.mobile;
if (mobileSheet) {
size.width = 'none';
size.height = 'calc(100dvh - 12px)';
}
const toggle = (event, closed) => {
const frame = event.currentTarget.closest('[data-pattern-frame]');
const panel = frame.querySelector('chatty-surface');
const launcher = frame.querySelector('[data-pattern-launcher]');
panel.hidden = closed;
frame.dataset.closed = String(closed);
const background = frame.querySelector('[data-sheet-page]');
if (background) background.inert = !closed && surface === 'ai-mode';
launcher.hidden = !closed;
if (closed) {
launcher.style.insetBlockEnd = `${Math.max(surface === 'ai-mode' ? 40 : 16, frame.getBoundingClientRect().bottom - innerHeight + 20)}px`;
launcher.focus({preventScroll: true});
} else {
const composer = panel.querySelector('chatty-composer');
const input = !composer.hidden
? composer.renderRoot.querySelector('textarea')
: (panel
.querySelector('chatty-contact-form:not([hidden])')
?.renderRoot.querySelector('chatty-text-field') ??
panel.querySelector('form chatty-text-field') ??
panel.querySelector('[data-welcome-invitation]:not([hidden]) chatty-button') ??
panel
.querySelector('chatty-pre-chat:not([hidden])')
?.renderRoot.querySelector('chatty-button'));
input?.focus({preventScroll: true});
}
};
const sender = message => {
const content = renderMessage?.(message) ?? {};
const messages = store.getState().messages;
const previous = messages[messages.indexOf(message) - 1];
if (message.senderType !== 'bot' || sameGroup(message, previous)) return content;
return {
...content,
sender: html`<span style="display:inline-flex;align-items:center;gap:6px"
><chatty-avatar size="sm" label="Assistant">A</chatty-avatar
>${content.sender ?? message.senderName ?? message.senderMeta?.name ?? 'Assistant'}</span
>`
};
};
return html`<style>
[data-pattern-frame] {
display: flex;
position: relative;
justify-content: center;
inline-size: 100%;
min-inline-size: 0;
}
[data-pattern-frame='classic'] {
justify-content: flex-end;
}
[data-pattern-frame] chatty-surface::part(header) {
padding: 0;
}
[data-pattern-frame='classic'] chatty-surface::part(header),
[data-pattern-frame='ai-mode'] chatty-surface::part(header) {
border-bottom-width: 0;
}
[data-pattern-frame] [hidden] {
display: none !important;
}
[data-pattern-header] {
display: flex;
align-items: center;
gap: 10px;
box-sizing: border-box;
min-inline-size: 0;
block-size: 52px;
padding: 0 16px;
}
[data-pattern-frame='classic'] [data-pattern-header] {
block-size: 56px;
background: var(--chatty-color-accent);
color: var(--chatty-color-on-accent);
}
[data-pattern-frame='classic'] [data-pattern-header] chatty-icon-button {
--chatty-color-border-focus: var(--chatty-color-on-accent);
}
[data-pattern-frame='admin'] [data-pattern-header] {
block-size: 68px;
padding: 8px 12px;
}
[data-pattern-header] chatty-avatar {
--chatty-avatar-size: 32px;
}
[data-pattern-frame='classic'] [data-pattern-header] chatty-avatar {
--chatty-avatar-background: #fff;
}
[data-pattern-frame='classic'] [data-pattern-header] chatty-avatar::part(base) {
color: #303030;
border: 1px solid #767676;
}
[data-pattern-actions] {
display: flex;
align-items: center;
gap: 8px;
}
[data-pattern-title] {
flex: 1;
min-inline-size: 0;
display: flex;
flex-direction: column;
}
[data-pattern-frame='admin'] [data-pattern-title] {
gap: 4px;
}
[data-pattern-frame='admin'] [data-pattern-title] strong {
display: flex;
align-items: center;
min-block-size: 28px;
font: var(--p-font-weight-semibold, 650) var(--p-text-heading-md-font-size, 14px) /
var(--p-text-heading-md-font-line-height, 20px) var(--p-font-family-sans, system-ui);
}
[data-pattern-title] strong {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
[data-pattern-header] chatty-icon-button {
--chatty-icon-button-size: 32px;
--chatty-icon-button-color: currentColor;
}
@media (max-width: 899px), (pointer: coarse) {
[data-pattern-header] chatty-icon-button {
--chatty-icon-button-size: 44px;
}
}
[data-pattern-launcher] {
position: absolute;
inset-inline-end: 0;
inset-block-end: 0;
}
[data-pattern-frame='ai-mode'] [data-pattern-launcher] {
inset-inline-end: auto;
inset-inline-start: 50%;
transform: translateX(-50%);
}
[data-pattern-frame='classic'] [data-pattern-launcher] {
--chatty-icon-button-size: 56px;
border-radius: 50%;
background: var(--chatty-color-accent);
--chatty-icon-button-color: var(--chatty-color-on-accent);
}
[data-sheet-mobile='true'] {
position: fixed;
inset: 0;
inline-size: 100vw;
}
[data-sheet-mobile='true'] chatty-surface::part(base) {
border-radius: 16px 16px 0 0;
}
[data-sheet-mobile='true'] chatty-surface {
position: relative;
z-index: 2;
margin-block-start: 12px;
}
[data-sheet-page],
[data-sheet-scrim] {
position: absolute;
inset: 0;
box-sizing: border-box;
}
[data-sheet-page] {
padding: 20px;
background: var(--chatty-color-bg-surface);
color: var(--chatty-color-text);
}
[data-sheet-scrim] {
z-index: 1;
border: 0;
background: rgb(0 0 0 / 40%);
animation: sheet-scrim 400ms ease;
}
[data-sheet-mobile='true'][data-closed='true'] [data-sheet-scrim] {
display: none;
}
[data-sheet-mobile='true'] [data-pattern-launcher] {
z-index: 3;
}
@keyframes sheet-scrim {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
[data-sheet-scrim] {
animation: none;
}
}
</style>
<div
data-pattern-frame=${surface}
data-sheet-mobile=${String(mobileSheet)}
data-closed="false"
style=${`block-size:calc(${size.height} + ${mobileSheet ? 12 : 0}px)`}
>
${
mobileSheet
? html`<div data-sheet-page .inert=${surface === 'ai-mode'}>
<p>Example storefront</p>
<chatty-button
variant="secondary"
type="button"
@click=${event => {
event.currentTarget.textContent = 'Products opened';
}}
>
Browse products
</chatty-button>
</div>
${surface === 'ai-mode' ? html`<button type="button" data-sheet-scrim tabindex="-1" aria-label="Close chat background" @click=${event => toggle(event, true)}></button>` : ''}`
: ''
}
<chatty-surface
data-chatty-surface=${surface}
data-chatty-theme=${surface === 'admin' ? 'light' : (document.documentElement.dataset.chattyTheme ?? document.documentElement.dataset.theme ?? 'light')}
style=${`inline-size:100%;max-inline-size:${mobileSheet ? 'none' : `${size.width}px`};--chatty-surface-height:${size.height}`}
.store=${store}
.registry=${registry ?? null}
viewer-type=${surface === 'admin' ? 'agent' : 'customer'}
.selfTypes=${surface === 'admin' ? ['agent', 'bot'] : null}
.renderMessage=${sender}
>
<div slot="header" data-pattern-header>
${headerStart ?? ''}
${surface === 'admin' ? '' : html`<chatty-avatar label="Store" .status=${status}>S</chatty-avatar>`}
<span data-pattern-title
><strong
>${title ?? (surface === 'admin' ? 'Customer conversation' : strings.header)}</strong
>${surface === 'admin' ? html`<chatty-badge size="sm" variant="secondary" style="align-self:flex-start">Customer</chatty-badge>` : status == null ? '' : html`<small data-pattern-status>${status === 'online' ? 'Open' : 'Closed'}</small>`}</span
>
<span data-pattern-actions>${headerActions ?? ''}</span>
${
surface === 'admin'
? ''
: html`<chatty-icon-button label="Close panel" @click=${event => toggle(event, true)}
>${IconClose()}</chatty-icon-button
>`
}
</div>
<chatty-thread .strings=${{bot: 'Assistant', ...strings}}></chatty-thread>${content ?? ''}
<chatty-composer
slot="footer"
?hidden=${composerHidden}
.label=${strings.message}
.sendLabel=${strings.send}
@chatty-send=${event => {
appendViewer(store, surface, event.detail.text);
if (onSend) onSend(event.detail.text, event.currentTarget);
else if (surface !== 'admin')
store.setMessages([
...store.getState().messages,
{
id: `fixture-${store.getState().messages.length}`,
senderType: 'bot',
text: `You asked: “${event.detail.text}”. I can help with that.`,
hasEventTime: false
}
]);
}}
></chatty-composer> </chatty-surface
>${
surface === 'admin'
? ''
: surface === 'ai-mode'
? html`<chatty-launcher
data-pattern-launcher
hidden
label="Open chat"
@chatty-open=${event => toggle(event, false)}
>${IconMessage({size: 20, slot: 'icon'})}Ask a question</chatty-launcher
>`
: html`<chatty-icon-button
data-pattern-launcher
hidden
size="lg"
label="Open chat"
@click=${event => toggle(event, false)}
>${IconMessage({size: 24})}</chatty-icon-button
>`
}
</div>`;
}
import '@avada/chatty-ui/elements/button.js';
export function Standard({surface}) {
const store = fixtureStore([
{id: 'transcript', senderType: 'bot', text: 'You can email this conversation to yourself.'}
]);
const content = html`
<form
aria-label="Email a transcript"
style="box-sizing:border-box;display:grid;gap:8px;width:100%;max-width:400px"
>
<label style="display:grid;gap:4px">
Email this transcript to
<input
class="Avada-Faq_Transcript-Email-Input"
aria-label="Email address"
type="email"
autocomplete="email"
value="you@example.com"
required
style="box-sizing:border-box;width:100%;min-height:40px;padding:8px 12px;border:1px solid var(--chatty-color-border);border-radius:8px;background:var(--chatty-color-bg-surface);color:inherit;font:inherit"
/>
</label>
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
<chatty-button variant="primary">Send</chatty-button>
<chatty-button variant="secondary">Cancel</chatty-button>
</div>
</form>
<style>
:host([data-chatty-surface='ai-mode']) form {
--chatty-button-primary-bg: #303030;
--chatty-button-primary-hover: color-mix(in srgb, #303030 85%, black);
--chatty-button-primary-active: var(--chatty-button-primary-hover);
}
</style>
`;
// Keep public Code executable rather than extracting only the static form.
return html`${patternShell({surface, store, content})}`;
}Prototype Button và các style đi kèm là chuẩn: package được port 1:1 từ prototype, và manifest phần tử được sinh từ cùng nguồn. Chưa surface nào dùng element thật; các mục Classic, AI Mode và Admin bên dưới mô tả React đang chạy. Admin · Knowledge files giữ Polaris. Lớp data-chatty-surface chọn token button riêng cho Classic, AI Mode và Admin; data-chatty-theme chọn Light/Dark. AI Mode dùng sm/md/lg 32/40/48px; radius 10/14/14px. Classic dùng 32/36/40px. Admin giữ size Polaris; large/plain dùng bodyMd, micro plain dùng bodySm, nên medium plain cao 32px theo line box. Token --chatty-button-md-height là baseline theo surface cho size; override --chatty-button-height vẫn đặt chiều cao control trực tiếp (ví dụ action Toast trên touch).
Element
| Element | Module |
|---|---|
chatty- |
@avada/ |
API
| Kind | Name | Type | Default | Description |
|---|---|---|---|---|
| attribute | variant |
primary, secondary, tertiary, plain | 'secondary' |
Mức nhấn của action; giá trị lạ quay về mặc định. |
| attribute | tone |
neutral, critical, success, caution | 'neutral' |
Ý nghĩa màu của action. |
| attribute | size |
sm, md, lg | 'md' |
Chiều cao và padding; mặc định md. |
| attribute | disabled |
boolean | false |
Chặn kích hoạt, vẫn nhận focus và báo aria- |
| attribute | loading |
boolean | false |
Hiện spinner, báo aria- |
| attribute | href |
string | '' |
URL http, https, mailto hoặc tel thì render link; URL khác bị bỏ. |
| attribute | label |
string | '' |
Tên truy cập khi nội dung chỉ là biểu tượng. |
| attribute | type |
button, submit, reset | 'button' |
submit và reset gọi form chứa element qua ElementInternals. |
| event | click |
MouseEvent | – | Kích hoạt native; bị chặn khi disabled hoặc loading. |
| slot | default | – | – | Nhãn của button. |
| slot | start |
– | – | Nội dung đứng trước nhãn. |
| slot | end |
– | – | Nội dung đứng sau nhãn. |
| part | base |
– | – | Control native (button hoặc a). |
| part | label |
– | – | Vùng chứa nhãn. |
| part | start |
– | – | Vùng chứa slot start. |
| part | end |
– | – | Vùng chứa slot end. |
| css- |
- |
– | – | Bo góc. |
| css- |
- |
– | – | Plain hover/ |
| css- |
- |
– | – | Plain interaction decoration; unset giữ base decoration. |
| css- |
- |
– | – | Plain focus radius; unset giữ base radius. |
| css- |
- |
– | – | Nền theo variant và tone. |
| css- |
- |
– | – | Màu chữ theo variant và tone. |
| css- |
- |
– | – | Màu viền theo variant và tone. |
| css- |
- |
– | – | Chiều cao control. |
| css- |
- |
– | – | Padding ngang. |
| css- |
- |
length- |
auto |
Bề rộng control; 100% giãn hết vùng chứa. |
Storefront mở rộng success/caution; Classic critical chưa có caller đang ship. AI Mode accent mặc định #303030 từ launcher; danger giữ đỏ AA #dc2626.
Variant mapping
| chatty-button | Classic | AI Mode | Admin (Polaris) |
|---|---|---|---|
| primary | Primary- |
accent | primary |
| secondary | Add to cart; action trong card dùng radius 10px | glass | secondary |
| tone=critical | Mở rộng | danger (AA) | primary critical |
| tertiary | ghost | ghost | tertiary |
| plain | Link hành động | Mở rộng cho link hành động, không gạch chân | plain, không gạch chân |
| secondary + tone=success | Mở rộng: nền secondary, chữ xanh | Mở rộng: nền glass, chữ xanh | secondary + tone=success |
Đối chiếu component React đang chạy ở từng mục surface bên dưới.
Intentional differences
<!-- Source for the intentional critical contrast difference: (--danger). -->
| Difference | Shipped | Standard | Why |
|---|---|---|---|
| Empty icon slots | AI Mode/ |
Slot start/ |
Nhãn và padding đúng kích thước nội dung |
| One API | Classic default/ |
Một API primary/ |
Caller chọn cùng ý nghĩa theo bảng mapping |
| Focus | Storefront outline 2px, offset 2px; Admin thường offset 1px; Polaris plain focus radius 12px và inset | Storefront giữ baseline; Admin dùng chung radius 8px, offset 1px | Focus nhất quán giữa các variant; không phải bản sao mọi caller Polaris |
| Disabled contrast | Classic dùng chữ #b5b5b5 trên nền disabled | Giữ paint đang ship | Control không hoạt động được miễn yêu cầu tương phản của WCAG 1.4.3 |
| Critical contrast | AI Mode critical #ef4444, chữ trắng chỉ đạt 3.76:1 | #dc2626, chữ trắng đạt 4.83:1 | Đạt 4.5:1 của WCAG 1.4.3; b1- |
| Reduced motion | AI Mode vẫn press scale khi bật reduced motion | Tắt scale theo tuỳ chọn reduced motion | Tôn trọng tuỳ chọn giảm chuyển động |
| Classic secondary in dark | Add to cart là khối trắng trong dark | Classic secondary in dark uses a dark fill instead of a white block (shipped Add to cart is white in dark); hover cũng dùng nền tối | Giữ chữ #eee đọc rõ khi nghỉ và hover |
| Success tone | Classic và AI Mode chưa có tone success chung; Admin secondary chữ xanh | Cả ba surface dùng secondary/ |
Cùng mức nhấn, không tạo khối mint; chữ đạt 4.5:1 trên glass kể cả hover/ |
Quyết định Success và Classic dark ở đây là lựa chọn của bộ chuẩn, chưa phải thay đổi trong widget đang chạy.
Classic
Ma trận variant, size và tone theo surface.
Show code
<div
class="button-variants"
role="group"
aria-label="Button variants and sizes"
style="box-sizing:border-box;display:grid;gap:8px;width:100%;max-width:400px"
>
<p style="margin:0">Button variants and sizes</p>
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
<chatty-button variant="primary">Send</chatty-button>
<chatty-button>Cancel</chatty-button>
<chatty-button variant="tertiary">Skip</chatty-button>
<chatty-button variant="plain">View order</chatty-button>
<chatty-button variant="primary" size="sm">Small</chatty-button>
<chatty-button variant="primary" size="lg">Large</chatty-button>
<chatty-button variant="primary" tone="critical">Delete</chatty-button>
<chatty-button variant="secondary" tone="success">Confirm</chatty-button>
</div>
</div>
<style>
:host([data-chatty-surface='ai-mode']) .button-variants {
--chatty-button-primary-bg: #303030;
--chatty-button-primary-hover: color-mix(in srgb, #303030 85%, black);
--chatty-button-primary-active: var(--chatty-button-primary-hover);
}
</style>Disabled, loading, link và nhãn truy cập của element.
Show code
<form
aria-label="Email a transcript"
style="box-sizing:border-box;display:grid;gap:8px;width:100%;max-width:400px"
>
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
<chatty-button variant="primary" disabled>Disabled</chatty-button>
<chatty-button variant="primary" loading>Sending</chatty-button>
<chatty-button href="https://example.com/orders">Open link</chatty-button>
<chatty-button label="Close chat">×</chatty-button>
</div>
</form>
<style>
:host([data-chatty-surface='ai-mode']) form {
--chatty-button-primary-bg: #303030;
--chatty-button-primary-hover: color-mix(in srgb, #303030 85%, black);
--chatty-button-primary-active: var(--chatty-button-primary-hover);
}
</style>Variants và sizes theo API; default in-chat dùng màu merchant.
Show code
import React from 'react';
import {Button, Spinner} from '@assets/components/ui';
import '@scripttag/v1/MuiComponents/EmailTranscript.scss';
export function Catalogue() {
return (
<div className="specimen-grid">
<section>
<h4>Variants</h4>
<div className="button-list">
{['default', 'outline', 'secondary', 'ghost', 'iconOnly', 'destructive'].map(variant => (
<Button
key={variant}
variant={variant}
className={variant === 'default' ? 'Avada-Faqs_Primary-Button' : undefined}
aria-label={variant === 'iconOnly' ? 'More options' : undefined}
>
{variant === 'iconOnly' ? '…' : variant}
</Button>
))}
</div>
</section>
<section>
<h4>Sizes</h4>
<div className="button-list">
{['sm', 'default', 'lg', 'icon', 'auto'].map(size => (
<Button
key={size}
size={size}
className="Avada-Faqs_Primary-Button"
aria-label={size === 'icon' ? 'More options' : undefined}
>
{size === 'icon' ? '…' : size}
</Button>
))}
</div>
</section>
</div>
);
}Idle, loading và email rỗng; JSX được trích đúng caller EmailTranscript.
Show code
import {Button, Typography, Spinner} from '@assets/components/ui';
<Button
variant="default"
className="Avada-Faqs_Primary-Button Avada-Faq_Message-Subscribe_Button--emailTranscript"
disabled={loading || !email}
onClick={e => {
e.stopPropagation();
return handleSubmitEmail();
}}
>
{loading ? (
<Spinner size="small" style={{color: '#ffffff'}} />
) : (
i18n(mailtoFallback ? 'Continue as email' : 'Send')
)}
</Button>Import / element
| Component / element | Import / file | Scope root |
|---|---|---|
Button + Spinner |
@assets/ |
.chatty- |
In-Button + Avada- + Spinner |
@assets/ |
.Avada- |
Anatomy
| Part | Element |
|---|---|
| 1 | Tag native a/href. |
| 2 | Nội dung children; caller thêm icon/ |
Placement / order
| Context | Order |
|---|---|
| In- |
Caller EmailTranscript đặt action gửi trong form; dùng Button + class Avada- |
| Primitive | Component nhận children, không tự tạo footer hay thứ tự nhiều action. |
Props
| Prop | Type | Values | Default | Notes |
|---|---|---|---|---|
variant |
string | default / outline / ghost / iconOnly / secondary / destructive | default | Fill và interaction utility. |
size |
string | default / sm / lg / icon / auto | default | Không tự tăng box trên mobile. |
disabled |
boolean | true / false | undefined | Native button nhận attribute; anchor không nhận disabled. |
href |
string | URL | undefined | Truthy đổi Tag thành a. |
iconOnly |
boolean | true / false | undefined | Ép variant iconOnly và size icon; inline background/ |
noBorder |
boolean | true / false | undefined | Inline border none. |
className |
string | CSS classes | undefined | Gộp cuối utility list. |
style |
object | CSS declarations | undefined | Merge cuối, có thể override inline icon/ |
children |
ReactNode | Caller content | undefined | Không có copy hay i18n mặc định. |
props |
attributes / handlers | Native attrs, onClick, aria-* | Caller | Spread vào Tag; caller đặt type cho form. |
Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
|---|---|---|---|---|---|---|---|
| sm | 32pxDerived(32px = h- |
0 / 12pxDerived(12px = px- |
Không khai báo | 8px | button- |
Native box | Không override theo viewport |
| default | 36pxDerived(36px = h- |
8pxDerived(8px = py- |
Không khai báo | 8px | button- |
Native box | Không override theo viewport |
| lg | 40pxDerived(40px = h- |
0 / 32pxDerived(32px = px- |
Không khai báo | 8px | button- |
Native box | Không override theo viewport |
| icon | 36pxDerived(36px = h- |
Theo utility | Không khai báo | 8px | button- |
Native box | iconOnly ép size icon |
| auto | Theo parent (h-) |
8pxDerived(8px = py- |
Không khai báo | 8px | button- |
Theo parent | Caller quyết định height của parent |
| Label desktop / mobile | Theo size | Theo size | Theo caller | Theo size | 12px / 16px → 15px / 22px; weight 500 | Không mở rộng hit area | JS mobile class khi mobileMaxWidth 899px |
Tokens
| Part | Token | Light | Dark |
|---|---|---|---|
| Primary fill | - |
#6366f1 | #6366f1 |
| Primary text | - |
#ffffff | #ffffff |
| Hover primary | - |
#4f46e5 | #4f46e5 |
| Neutral fill | - |
#f1f5f9 | #f1f5f9 |
| Neutral text | - |
#64748b | Merchant secondary when overridden by popup theme |
| Destructive | - |
#ef4444 | #ef4444 |
| Merchant action | - / - |
Màu merchant theo caller | fill #ffffff / text #303030, Dark override thắng biến merchant |
| Focus | - |
Merchant faqsTextColor, fallback #303030 | Merchant faqsTextColor, fallback #eee |
| Neutral foreground | - |
#0f172a | Theo faqsTextColor của merchant |
| Border | - |
#e2e8f0 | Same unless merchant overrides |
| Shared radius | - |
8px; rounded- |
Same |
States
| State | Trigger | Visual change (values) | ARIA/attribute |
|---|---|---|---|
| Hover default | pointer | hover:chatty:bg-; màu theo Tokens |
Không thêm ARIA |
| Hover outline | pointer | hover:chatty:bg-; màu theo Tokens |
Không thêm ARIA |
| Hover ghost | pointer | hover:chatty:bg-; màu theo Tokens |
Không thêm ARIA |
| Hover iconOnly | pointer | hover:chatty:bg-; màu theo Tokens |
Không thêm ARIA |
| Hover secondary | pointer | hover:chatty:bg-; màu theo Tokens |
Không thêm ARIA |
| Hover destructive | pointer | hover:chatty:bg-; màu theo Tokens |
Không thêm ARIA |
| Pressed | pointer down / caller selected | No dedicated active fill; caller sets aria-props |
Caller state |
| Focus- |
keyboard | 2px ring utility; popup outline 2px / offset 2px (outline-) |
Native focus |
| Disabled | disabled true | opacity-, pointer- |
Native disabled only without href |
| Primary- |
pointer | opacity 0.8 (opacity), transition 0.2s ease- |
Caller label remains |
| Primary- |
disabled | Light text #b5b5b5 / fill #00000014; Dark text #b5b5b5 / fill #ffffff14 | Native disabled |
| Loading từ caller | loading || !email | Label Send được thay bằng Spinner small; disabled không cho kích hoạt lặp. Không có prop loading nội tại. | Caller hiện tại không đặt aria- |
Behaviour
| Interaction | Result |
|---|---|
| Keyboard | Native button gets browser Enter/ |
| Overflow / long translation | inline-inline-); no built- |
| RTL / order | No custom RTL branch; caller composes icon and children in DOM order. |
| Loading / errors | No built-props forwarded, caller owns async lifecycle. |
Copy
| String | i18n key | Where |
|---|---|---|
| Send | Send | EmailTranscript i18n caller (Send) |
| Caller label | Caller- |
Shared children does not localize strings. |
Source
| File | Evidence |
|---|---|
| Shared API | |
| Classic scope and caller class | |
| Type role and breakpoint |
AI Mode
Ma trận variant, size và tone theo surface.
Show code
<div
class="button-variants"
role="group"
aria-label="Button variants and sizes"
style="box-sizing:border-box;display:grid;gap:8px;width:100%;max-width:400px"
>
<p style="margin:0">Button variants and sizes</p>
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
<chatty-button variant="primary">Send</chatty-button>
<chatty-button>Cancel</chatty-button>
<chatty-button variant="tertiary">Skip</chatty-button>
<chatty-button variant="plain">View order</chatty-button>
<chatty-button variant="primary" size="sm">Small</chatty-button>
<chatty-button variant="primary" size="lg">Large</chatty-button>
<chatty-button variant="primary" tone="critical">Delete</chatty-button>
<chatty-button variant="secondary" tone="success">Confirm</chatty-button>
</div>
</div>
<style>
:host([data-chatty-surface='ai-mode']) .button-variants {
--chatty-button-primary-bg: #303030;
--chatty-button-primary-hover: color-mix(in srgb, #303030 85%, black);
--chatty-button-primary-active: var(--chatty-button-primary-hover);
}
</style>Disabled, loading, link và nhãn truy cập của element.
Show code
<form
aria-label="Email a transcript"
style="box-sizing:border-box;display:grid;gap:8px;width:100%;max-width:400px"
>
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
<chatty-button variant="primary" disabled>Disabled</chatty-button>
<chatty-button variant="primary" loading>Sending</chatty-button>
<chatty-button href="https://example.com/orders">Open link</chatty-button>
<chatty-button label="Close chat">×</chatty-button>
</div>
</form>
<style>
:host([data-chatty-surface='ai-mode']) form {
--chatty-button-primary-bg: #303030;
--chatty-button-primary-hover: color-mix(in srgb, #303030 85%, black);
--chatty-button-primary-active: var(--chatty-button-primary-hover);
}
</style>Các variant và size CSS kit trong một grid.
Show code
import React from 'react';
import '@scripttag/v2/ui/control.scss';
export function Catalogue() {
return (
<div className="specimen-grid" style={{minWidth: 0}}>
<section style={{minWidth: 0}}>
<h4>Variants</h4>
<div
className="button-list"
style={{
alignItems: 'flex-start',
width: '100%',
minWidth: 0,
'--faqsBtnPopupColor': '#303030',
'--accent': '#303030',
'--accent-deep': 'color-mix(in srgb, #303030 85%, black)'
}}
>
{['accent', 'glass', 'ghost', 'danger'].map(variant => (
<button
key={variant}
type="button"
className={`chatty-btn chatty-btn--${variant} chatty-btn--md`}
>
{variant}
</button>
))}
</div>
</section>
<section style={{minWidth: 0}}>
<h4>Sizes</h4>
<div
className="button-list"
style={{
alignItems: 'flex-start',
width: '100%',
minWidth: 0,
'--faqsBtnPopupColor': '#303030',
'--accent': '#303030',
'--accent-deep': 'color-mix(in srgb, #303030 85%, black)'
}}
>
<button type="button" className="chatty-btn chatty-btn--accent">
Base
</button>
<button type="button" className="chatty-btn chatty-btn--accent chatty-btn--md">
Medium
</button>
<button type="button" className="chatty-btn chatty-btn--accent chatty-btn--lg">
Large
</button>
<button
type="button"
className="chatty-btn chatty-btn--glass chatty-btn--block"
style={{width: '100%', maxWidth: '100%'}}
>
Block
</button>
</div>
</section>
<section style={{minWidth: 0}}>
<h4>Long label</h4>
<div style={{overflowX: 'auto', minWidth: 0}}>
<button
type="button"
className="chatty-btn chatty-btn--glass"
style={{maxWidth: '100%', whiteSpace: 'normal', height: 'auto', minHeight: 44}}
>
Tiếp tục xem lựa chọn phù hợp với nhu cầu của bạn
</button>
</div>
</section>
</div>
);
}Hover/focus, disabled và loading class.
Show code
import React from 'react';
import '@scripttag/v2/ui/control.scss';
export function States() {
return (
<div
className="button-list"
style={{
alignItems: 'flex-start',
'--faqsBtnPopupColor': '#303030',
'--accent': '#303030',
'--accent-deep': 'color-mix(in srgb, #303030 85%, black)'
}}
>
<button type="button" className="chatty-btn chatty-btn--accent">
Hover / focus
</button>
<button type="button" className="chatty-btn chatty-btn--accent" disabled>
Disabled accent
</button>
<button type="button" className="chatty-btn chatty-btn--glass" disabled>
Disabled glass
</button>
<button
type="button"
className="chatty-btn chatty-btn--accent is-loading"
disabled
aria-busy="true"
aria-label="Saving"
>
<span className="chatty-btn-label">Save</span>
<span className="chatty-btn-spinner" aria-hidden="true" />
</button>
</div>
);
}Import / element
| Component / element | Import / file | Scope root |
|---|---|---|
button |
.chatty- |
|
Native button caller |
.aimode- |
Anatomy
| Part | Element |
|---|---|
| 1 | Native button with chatty- |
| 2 | Loading holds text in chatty-, adds chatty- |
Placement / order
| Context | Order |
|---|---|
| Continue with AI | Caller wraps one native action, disabled while sending. |
Props
| Prop | Type | Values | Default | Notes |
|---|---|---|---|---|
| class | string | chatty- |
Caller | CSS kit has no React prop wrapper (chatty-). |
| disabled | native boolean | true / false | false | Accent/disabled). |
| is- |
CSS class | Caller toggle | absent | Caller also disables and supplies spinner (is-). |
Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
|---|---|---|---|---|---|---|---|
| base | min- |
0 12px | 6px | 10px via radius- |
button- |
Native box; no extra hit- |
No size media query |
| md | min- |
0 16px | 6px | 14px via radius- |
button- |
Native box | class- |
| lg | min- |
0 24px | 6px | 14px via radius- |
heading- |
Native box | class- |
| block | According to size | According to size | 6px | According to size | According to size | width 100% | class- |
| Label | Desktop / mobile | — | — | — | button- |
No extra hit- |
JS .is- |
| Large label | According to lg box | — | — | — | heading-heading-) |
No extra hit- |
JS .is- |
Tokens
| Part | Token | Light | Dark |
|---|---|---|---|
| Accent | - |
Merchant - |
Same definition |
| On accent | - |
Merchant label, fallback white | Same definition |
| Hover accent | - |
85% accent mixed with black | Same definition |
| Glass fill | - |
rgba(20,19,24,0.07) below 900px; rgba(255,255,255,0.65) at min- |
rgba(255,255,255,0.1) |
| Glass edge | - |
rgba(20,19,24,0.08) | rgba(255,255,255,0.12) |
| Text | - |
rgba(20,19,24,0.94) | rgba(255,255,255,0.96) |
| Muted text | - |
rgba(20,19,24,0.62) | rgba(255,255,255,0.62) |
| Hover neutral | - |
rgba(20,19,24,0.1) below 900px; rgba(255,255,255,0.92) at min- |
rgba(255,255,255,0.14) |
| Danger | - |
#ef4444 | #ef4444 |
| Transition duration / easing | -; -; out- |
200msDerived(200ms = duration(200)); cubic- |
Same |
| Canvas | - |
#f6f4f0 | #131215 |
States
| State | Trigger | Visual change (values) | ARIA/attribute |
|---|---|---|---|
| Hover | pointer | accent-brightness() |
Native |
| Pressed | active not disabled | scale 0.965 (scale() |
No selected API |
| Disabled | native disabled | accent uses fill--) |
Native disabled |
| Focus- |
keyboard | Không có rule focus riêng trong kit; browser vẽ outline mặc định. | Native |
| Loading | is- |
opacity 0.85, cursor progress; hidden label (0.85) |
Caller aria- |
| Spinner | loading child | 16×16px border 2px; 0.7s linear infinite (0.7s) |
Caller aria- |
Behaviour
| Interaction | Result |
|---|---|
| Long text | nowrap: no truncation or wrap; ensure available width or a controlled overflow region. |
| Keyboard / RTL | Native button activation; no kit-button). |
| Async | ContinueWithAI resets sending in finally; its disabled action has no spinner child. |
| Transition timing | background / border-- and -; transform is 0.18s with same ease. Tokens alias - |
Copy
| String | i18n key | Where |
|---|---|---|
| Continue with AI | Continue with AI button | Caller uses t |
Source
| File | Evidence |
|---|---|
| CSS kit geometry and states | |
| Theme roots and palette |
Admin
Ma trận variant, size và tone theo surface.
Show code
<div
class="button-variants"
role="group"
aria-label="Button variants and sizes"
style="box-sizing:border-box;display:grid;gap:8px;width:100%;max-width:400px"
>
<p style="margin:0">Button variants and sizes</p>
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
<chatty-button variant="primary">Send</chatty-button>
<chatty-button>Cancel</chatty-button>
<chatty-button variant="tertiary">Skip</chatty-button>
<chatty-button variant="plain">View order</chatty-button>
<chatty-button variant="primary" size="sm">Small</chatty-button>
<chatty-button variant="primary" size="lg">Large</chatty-button>
<chatty-button variant="primary" tone="critical">Delete</chatty-button>
<chatty-button variant="secondary" tone="success">Confirm</chatty-button>
</div>
</div>
<style>
:host([data-chatty-surface='ai-mode']) .button-variants {
--chatty-button-primary-bg: #303030;
--chatty-button-primary-hover: color-mix(in srgb, #303030 85%, black);
--chatty-button-primary-active: var(--chatty-button-primary-hover);
}
</style>Disabled, loading, link và nhãn truy cập của element.
Show code
<form
aria-label="Email a transcript"
style="box-sizing:border-box;display:grid;gap:8px;width:100%;max-width:400px"
>
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
<chatty-button variant="primary" disabled>Disabled</chatty-button>
<chatty-button variant="primary" loading>Sending</chatty-button>
<chatty-button href="https://example.com/orders">Open link</chatty-button>
<chatty-button label="Close chat">×</chatty-button>
</div>
</form>
<style>
:host([data-chatty-surface='ai-mode']) form {
--chatty-button-primary-bg: #303030;
--chatty-button-primary-hover: color-mix(in srgb, #303030 85%, black);
--chatty-button-primary-active: var(--chatty-button-primary-hover);
}
</style>Các variant và size Polaris trong một grid.
Show code
import React from 'react';
import {AppProvider, Button} from '@shopify/polaris';
function ButtonTarget() {
return <div data-button-target style={{fontFamily:'var(--chatty-type-family, ShopifyInter, sans-serif)',fontSize:12,lineHeight:'16px',padding:0}}><details><summary>Inbox Target preview and states</summary><p>Target Button: primary, secondary, tertiary, plain; tone critical; hover, pressed, focus, disabled, loading; slot icon và slot kbd. Admin 28px, radius action full; token chatty-ui theo giá trị 2.0. Dùng ở Assign to me / Resolve / Reopen (32), Send (13), filter pill (7), Done (24), Good/Needs fix.</p><a href="/maps/inbox-target-overview.webp"><img src="/maps/inbox-target-overview.webp" alt="Inbox Button design target" style={{display:'block',maxWidth:'100%',height:'auto'}}/></a><p>Ảnh mock chỉ chứng minh phần đã vẽ, không phải API đã ship. Mẫu giá trị Light/Dark ở Colour & elevation.</p></details></div>;
}
export function Catalogue() {
return (
<div className="specimen-grid">
<section>
<h4>Variants</h4>
<AppProvider i18n={{Polaris: {Button: {spinnerAccessibilityLabel: 'Loading'}}}}>
<div className="button-list" style={{alignItems: 'flex-start'}}>
{['primary', 'secondary', 'tertiary', 'plain', 'monochromePlain'].map(variant => (
<Button key={variant} variant={variant}>
{variant}
</Button>
))}
<Button tone="critical" variant="primary">
Delete
</Button>
<Button tone="success">Success</Button>
</div>
</AppProvider>
</section>
<section>
<h4>Sizes</h4>
<AppProvider i18n={{}}>
<div className="button-list" style={{alignItems: 'flex-start'}}>
{['micro', 'slim', 'medium', 'large'].map(size => (
<Button size={size} key={size}>
{size}
</Button>
))}
</div>
</AppProvider>
</section>
<section>
<h4>Long label</h4>
<AppProvider i18n={{}}>
<Button fullWidth textAlign="start">
Lưu thay đổi và tiếp tục thiết lập cửa hàng của bạn
</Button>
</AppProvider>
<ButtonTarget/>
</section>
</div>
);
}Disabled, selected, loading, disclosure và URL.
Show code
import React from 'react';
import {AppProvider, Button} from '@shopify/polaris';
function ButtonTarget() {
return <div data-button-target style={{fontFamily:'var(--chatty-type-family, ShopifyInter, sans-serif)',fontSize:12,lineHeight:'16px',padding:0}}><details><summary>Inbox Target preview and states</summary><p>Target Button: primary, secondary, tertiary, plain; tone critical; hover, pressed, focus, disabled, loading; slot icon và slot kbd. Admin 28px, radius action full; token chatty-ui theo giá trị 2.0. Dùng ở Assign to me / Resolve / Reopen (32), Send (13), filter pill (7), Done (24), Good/Needs fix.</p><a href="/maps/inbox-target-overview.webp"><img src="/maps/inbox-target-overview.webp" alt="Inbox Button design target" style={{display:'block',maxWidth:'100%',height:'auto'}}/></a><p>Ảnh mock chỉ chứng minh phần đã vẽ, không phải API đã ship. Mẫu giá trị Light/Dark ở Colour & elevation.</p></details></div>;
}
export function States() {
return (
<AppProvider i18n={{Polaris: {Button: {spinnerAccessibilityLabel: 'Loading'}}}}>
<div className="button-list" style={{alignItems: 'flex-start'}}>
<Button>Hover / focus</Button>
<Button disabled>Disabled</Button>
<Button pressed>Selected</Button>
<Button loading>Save</Button>
<Button disclosure>Actions</Button>
<Button url="#details">Details</Button>
</div>
</AppProvider>
);
}Import / element
| Component / element | Import / file | Scope root |
|---|---|---|
Button |
@shopify/ |
Global Polaris stylesheet + AppProvider context; caller .Avada- |
Anatomy
| Part | Element |
|---|---|
| 1 | Native semantics through Button, text/ |
| 2 | Caller may supply SettingsIcon for customize. |
Placement / order
| Context | Order |
|---|---|
| Widget mode | Customize action is sibling of select button (Button). |
Props
| Prop | Type | Values | Default | Notes |
|---|---|---|---|---|
| variant | string | plain / primary / secondary / tertiary / monochromePlain | secondary |
Runtime default. |
| size | string | micro / slim / medium / large | medium |
Runtime default. |
| loading / disabled | boolean | true / false | false | disabled || loading disables interaction. |
| pressed | boolean | true / false | false | Selected CSS only when not disabled and no URL (pressed). |
| tone / textAlign / fullWidth | string / boolean | critical / success; left,right,center,start,end | center / false | Layout/textAlign). |
| icon / disclosure | IconSource / boolean | Optional icon; up/ |
undefined | Library chooses icon and placeholder (disclosure). |
| url / submit / accessibilityLabel | string / boolean | Navigation, submit, icon- |
undefined / false | Caller-url). |
| children | ReactNode | Text/ |
undefined | Passed through Text markup (children). |
| id | string | Element id | undefined | Forwarded (id). |
| external / download / target | boolean / boolean or string / string | Link attributes | undefined | Used with url (external, download, target). |
| role / ariaControls / ariaExpanded / ariaDescribedBy / ariaChecked | string / string / boolean / string / boolean or mixed | Caller ARIA | undefined | Named API fields (role, ariaControls, ariaExpanded, ariaDescribedBy, ariaChecked). |
| onClick / onFocus / onBlur / onKeyDown / onKeyPress / onKeyUp / onMouseEnter / onTouchStart / onPointerDown | function | Caller handlers | undefined | Named callbacks, not arbitrary rest props (onClick, onPointerDown). |
| removeUnderline / dataPrimaryLink | boolean | Optional link rendering flags | undefined | Explicitly accepted (removeUnderline, dataPrimaryLink). |
Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
|---|---|---|---|---|---|---|---|
| micro | 24px / 28px | 4px / 8px | 2px | 8px | bodySm | Min box | CSS min- |
| slim / medium | 28px / 32px | 6px / 12px | 2px | 8px | bodySm | Min box | CSS min- |
| large | 32px / 36px | 6px / 12px | 2px | 8px | bodyMd | Min box | CSS min- |
| Label bodySm | Theo size | Theo size | Theo size | Theo size | 12px / 16px | Native box | Mọi size trừ large và plain không phải micro |
| Label bodyMd | Theo size | Theo size | Theo size | Theo size | 13px / 20px | Native box | large hoặc plain / monochromePlain không phải micro |
| Weight medium | Root- |
Theo size | Theo size | Theo size | medium 550 | Native box | light- |
| Weight semibold (primary dưới mdUp) | Root- |
Theo size | Theo size | Theo size | semibold 650 | Native box | light- |
| Weight regular (plain) | Root- |
Theo size | Theo size | Theo size | regular 450 | Native box | light- |
| light- |
Theo size | Theo size | Theo size | Theo size | 14px / 20px | Native box | Theme class p- |
| light- |
Theo size | Theo size | Theo size | Theo size | 16px / 24px | Native box | Theme class p- |
Tokens
| Part | Token | Light | Dark |
|---|---|---|---|
| Radius | - |
8px | No Dark skin |
| Internal spacing | - |
2px | No Dark skin |
| Text | - |
rgba(48,48,48,1) | No Dark skin |
| Surface | - |
rgba(255,255,255,1) | No Dark skin |
| Focus | - |
#005bd3 | No Dark skin |
States
| State | Trigger | Visual change (values) | ARIA/attribute |
|---|---|---|---|
| Hover / active | pointer | Library swaps background / color / shadow (-). |
Native |
| Focus- |
keyboard | 2px outline; 1px offset | Native |
| Disabled | disabled or loading | No shadow, pointer-pointer-). |
Native disabled / aria- |
| Pressed | pressed true | Selected background / text / shadow (-). |
aria- |
| Loading | loading true | Original label remains in layout, spinner small (Spinner). |
aria- |
Behaviour
| Interaction | Result |
|---|---|
| Action / link | URL/url). |
| Translation / wrap | Text via library children; no guide- |
| Library version | Pinned dependency 13.9.5; source guard validates owner pin. |
Copy
| String | i18n key | Where |
|---|---|---|
| Customize | Caller literal | WidgetModeCard tooltip and accessibilityLabel (Customize). |
| Loading | Polaris. |
Library spinner i18n (spinnerAccessibilityLabel). |
Source
| File | Evidence |
|---|---|
| Product owner/ |
|
| Pinned dependency API | |
| Pinned dependency API | |
| Pinned dependency layout |
Admin · Knowledge files
Shared variants và sizes dưới override Knowledge files.
Show code
import React, {useState} from 'react';
import {Button} from '@avada/chatty-ui/components/button.js';
export function Catalogue() {
return (
<div className="specimen-grid">
<section>
<h4>Variants</h4>
<div className="button-list">
<Button data-primary>Add to cart</Button>
<Button variant="outline">View details</Button>
<Button variant="secondary">Save selection</Button>
<Button variant="ghost">Later</Button>
<Button variant="iconOnly" aria-label="More options">
…
</Button>
<Button variant="destructive">Delete product</Button>
</div>
</section>
<section>
<h4>Sizes</h4>
<div className="button-list">
{['sm', 'default', 'lg', 'icon', 'auto'].map(size => (
<div key={size} style={{height: size === 'auto' ? 56 : undefined}}>
<Button size={size} aria-label={size === 'icon' ? 'More options' : undefined}>
{size === 'icon' ? '…' : size}
</Button>
</div>
))}
</div>
</section>
</div>
);
}Hover, focus, disabled và aria-pressed do caller.
Show code
import React, {useState} from 'react';
import {Button} from '@avada/chatty-ui/components/button.js';
export function States() {
const [pressed, setPressed] = useState(false);
return (
<div className="button-list">
<Button data-state="hover" variant="outline">
Hover here
</Button>
<Button
data-state="pressed"
variant="secondary"
aria-pressed={pressed}
onClick={() => setPressed(!pressed)}
>
Pressed: {pressed ? 'selected' : 'not selected'}
</Button>
<Button data-state="focus" variant="ghost">
Focus with Tab
</Button>
<Button disabled>Disabled</Button>
</div>
);
}Import / element
| Component / element | Import / file | Scope root |
|---|---|---|
Button |
@avada/ |
.kb- |
| Style owner | KnowledgeFiles.button |
.kb- |
Anatomy
| Part | Element |
|---|---|
| 1 | Tag native a/href. |
| 2 | Nội dung children; caller thêm icon/ |
Placement / order
| Context | Order |
|---|---|
| Shared component | Caller decides order; children rendered without grouping. |
Props
| Prop | Type | Values | Default | Notes |
|---|---|---|---|---|
variant |
string | default / outline / ghost / iconOnly / secondary / destructive | default | Fill và interaction utility. |
size |
string | default / sm / lg / icon / auto | default | Không tự tăng box trên mobile. |
disabled |
boolean | true / false | undefined | Native button nhận attribute; anchor không nhận disabled. |
href |
string | URL | undefined | Truthy đổi Tag thành a. |
iconOnly |
boolean | true / false | undefined | Ép variant iconOnly và size icon; inline background/ |
noBorder |
boolean | true / false | undefined | Inline border none. |
className |
string | CSS classes | undefined | Gộp cuối utility list. |
style |
object | CSS declarations | undefined | Merge cuối, có thể override inline icon/ |
children |
ReactNode | Caller content | undefined | Không có copy hay i18n mặc định. |
props |
attributes / handlers | Native attrs, onClick, aria-* | Caller | Spread vào Tag; caller đặt type cho form. |
Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
|---|---|---|---|---|---|---|---|
| All native button sizes | 32px | 0 / 10px | Không khai báo | 8px | 13px / 20px; weight 450 | Native box | Page selector ghi đè utility; font:inherit thắng khai báo weight trong :where |
| Anchor | Theo utility | Theo utility | Caller | Theo utility | Theo inherited type | Native link | Selector button không áp lên anchor |
Tokens
| Part | Token | Light | Dark |
|---|---|---|---|
| Fill | - |
white | No Dark skin |
| Text | - |
#303030 | No Dark skin |
| Border | - |
Polaris light token | No Dark skin |
| Focus | - |
#005bd3 | No Dark skin |
States
| State | Trigger | Visual change (values) | ARIA/attribute |
|---|---|---|---|
| Hover | pointer | bg--) |
Native |
| Disabled | disabled | opacity 0.48, not-0.48) |
Native disabled |
| Focus- |
keyboard | outline 2px, offset 2px (outline-) |
Native |
| Pressed | caller- |
No additional selected fill; caller forwards props. |
Caller aria- |
| Loading | caller async | Not available built-children. |
Caller aria- |
Behaviour
| Interaction | Result |
|---|---|
| Surface boundary | Styles target non-button; anchors keep shared utility behavior. |
| RTL / overflow | Không có rule RTL hay clamp riêng cho page button; caller quản lý text. |
| No Dark skin | Page skin hiện dùng Light; preview không cung cấp Dark. |
Copy
| String | i18n key | Where |
|---|---|---|
| Caller label | Caller- |
children from shared component. |
Source
| File | Evidence |
|---|---|
| Page scope, native button override | |
| Shared prop surface |
Do / Don't
Accessibility
Các tỷ lệ dưới đây đo ở foreground/background đã composite trong fixture merchant của preview. Merchant palette đổi thì đo lại; admin chỉ có Light. Disabled được loại khỏi phép đánh giá chữ đang hoạt động.
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
|---|---|---|---|---|
| Classic | Native button hoặc anchor, tên từ children | Button Enter/ |
Caller hiện tại không đặt live region trên action | Primitive 4.47:1Measured(#ffffff / #6366f1 = 4.47:1); destructive 3.76:1Measured(#ffffff / #ef4444 = 3.76:1); secondary Light 4.34:1Measured(#64748b / #f1f5f9 = 4.34:1); outline/ |
| Classic loading | Spinner thay label | Nút disabled | Không aria- |
Light: spinner #ffffff trên fill disabled #00000014: 1.19:1Measured(#ffffff / #00000014 over #ffffff = 1.19:1) |
| AI Mode | Native button, tên do caller | Native activation; kit chưa có focus- |
Caller tự cung cấp busy status | danger 3.76:1Measured(#ffffff / #ef4444 = 3.76:1); glass - |
| Admin | Native semantics từ Button / UnstyledButton | Loading / disabled không kích hoạt; focus theo bảng States | Spinner có localized accessible label | Primary 13.20:1Measured(#ffffff / #303030 = 13.20:1); secondary 13.20:1Measured(#303030 / #ffffff = 13.20:1); critical 6.00:1Measured(#ffffff / #c70a24 = 6.00:1); success text 10.09:1Measured(#014b40 / #ffffff = 10.09:1) |
| Admin · Knowledge files | Shared children cung cấp tên | Native button; outline của page | Caller- |
Các button variant trên Light 13.20:1Measured(#303030 / #ffffff = 13.20:1); anchor giữ shared style |
Target
-
.kb-ide button