On this page

Button

Chọn đúng API và giá trị đang chạy cho Classic, AI Mode, Admin và Knowledge files.

Copy page as MarkdownRead Markdown ↗

Key rules

  • Classic: action chính trong chat dùng Button + Avada-Faqs_Primary-Button và Spinner từ đườ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 Button chị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

Standard
LightDarkDesktopMobile

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
chatty-button.element.jsWrap code linesCopy
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-button @avada/chatty-ui/elements/button.js

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-disabled.
attribute loading boolean false Hiện spinner, báo aria-busy và chặn kích hoạt.
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-property --chatty-button-radius – – Bo góc.
css-property --chatty-button-plain-bg-hover – – Plain hover/pressed fill; unset giữ tertiary fill.
css-property --chatty-button-plain-decoration-hover – – Plain interaction decoration; unset giữ base decoration.
css-property --chatty-button-plain-focus-radius – – Plain focus radius; unset giữ base radius.
css-property --chatty-button-background – – Nền theo variant và tone.
css-property --chatty-button-color – – Màu chữ theo variant và tone.
css-property --chatty-button-border-color – – Màu viền theo variant và tone.
css-property --chatty-button-height – – Chiều cao control.
css-property --chatty-button-padding-inline – – Padding ngang.
css-property --chatty-button-width length-percentage, auto 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-Button 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/Polaris không có hai slot icon rỗng Slot start/end rỗng không chiếm chỗ; bỏ tổng 12px thừa của prototype cũ Nhãn và padding đúng kích thước nội dung
One API Classic default/outline; AI accent/glass/ghost; Polaris variant và tone Một API primary/secondary/tertiary/plain cộng tone 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-chatty nên port theo
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/glass và chữ xanh; storefront Light dùng #014b40 Cùng mức nhấn, không tạo khối mint; chữ đạt 4.5:1 trên glass kể cả hover/pressed

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

Standard
LightDarkDesktopMobile

Ma trận variant, size và tone theo surface.

Show code
chatty-button.element.jsWrap code linesCopy
<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>
Standard
LightDarkDesktopMobile

Disabled, loading, link và nhãn truy cập của element.

Show code
chatty-button.element.jsWrap code linesCopy
<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>
Current (React), being replaced
LightDarkDesktopMobile

Variants và sizes theo API; default in-chat dùng màu merchant.

Show code
button-classic.jsxWrap code linesCopy
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>
  );
}
Current (React), being replaced
LightDarkDesktopMobile

Idle, loading và email rỗng; JSX được trích đúng caller EmailTranscript.

Show code
EmailTranscript.jsWrap code linesCopy
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/components/ui .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup
In-chat primary action: Button + Avada-Faqs_Primary-Button + Spinner @assets/components/ui .Avada-Faqs_Popup; class màu merchant của caller

Anatomy

Part Element
1 Tag native a/button chọn qua href.
2 Nội dung children; caller thêm icon/spinner.

Placement / order

Context Order
In-chat primary action Caller EmailTranscript đặt action gửi trong form; dùng Button + class Avada-Faqs_Primary-Button, khi loading thay label bằng Spinner. Trong parent .Avada-Faqs_Body--chatDetail_EmailTranscript, EmailTranscript.scss ghi đè height 40px, width 100% và radius 10px. Không có Cancel trong caller này.
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/border/outline none.
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/noBorder.
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-8 × 4px) 0 / 12pxDerived(12px = px-3 × 4px) Không khai báo 8px button-label Native box Không override theo viewport
default 36pxDerived(36px = h-9 × 4px) 8pxDerived(8px = py-2 × 4px) / 16pxDerived(16px = px-4 × 4px) Không khai báo 8px button-label Native box Không override theo viewport
lg 40pxDerived(40px = h-10 × 4px) 0 / 32pxDerived(32px = px-8 × 4px) Không khai báo 8px button-label Native box Không override theo viewport
icon 36pxDerived(36px = h-9 × 4px) × 36pxDerived(36px = w-9 × 4px) Theo utility Không khai báo 8px button-label Native box iconOnly ép size icon
auto Theo parent (h-full) 8pxDerived(8px = py-2 × 4px) / 16pxDerived(16px = px-4 × 4px) Không khai báo 8px button-label 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 --chatty-primary #6366f1 #6366f1
Primary text --chatty-primary-foreground #ffffff #ffffff
Hover primary --chatty-primary-hover #4f46e5 #4f46e5
Neutral fill --chatty-muted #f1f5f9 #f1f5f9
Neutral text --chatty-muted-foreground #64748b Merchant secondary when overridden by popup theme
Destructive --chatty-destructive #ef4444 #ef4444
Merchant action --faqsBtnPopupColor / --faqsFloatBtnLabelColor Màu merchant theo caller fill #ffffff / text #303030, Dark override thắng biến merchant
Focus --chatty-ring Merchant faqsTextColor, fallback #303030 Merchant faqsTextColor, fallback #eee
Neutral foreground --chatty-foreground #0f172a Theo faqsTextColor của merchant
Border --chatty-border #e2e8f0 Same unless merchant overrides
Shared radius --chatty-radius-md 8px; rounded-md maps to this token Same

States

State Trigger Visual change (values) ARIA/attribute
Hover default pointer hover:chatty:bg-primary-hover; màu theo Tokens Không thêm ARIA
Hover outline pointer hover:chatty:bg-muted; màu theo Tokens Không thêm ARIA
Hover ghost pointer hover:chatty:bg-muted; màu theo Tokens Không thêm ARIA
Hover iconOnly pointer hover:chatty:bg-muted; màu theo Tokens Không thêm ARIA
Hover secondary pointer hover:chatty:bg-muted/80; màu theo Tokens Không thêm ARIA
Hover destructive pointer hover:chatty:bg-destructive/90; màu theo Tokens Không thêm ARIA
Pressed pointer down / caller selected No dedicated active fill; caller sets aria-pressed through props Caller state
Focus-visible keyboard 2px ring utility; popup outline 2px / offset 2px (outline-offset) Native focus
Disabled disabled true opacity-50, pointer-events-none Native disabled only without href
Primary-Button hover pointer opacity 0.8 (opacity), transition 0.2s ease-in Caller label remains
Primary-Button disabled 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-busy

Behaviour

Interaction Result
Keyboard Native button gets browser Enter/Space activation; anchor uses native link behavior.
Overflow / long translation inline-flex + fixed size utilities (inline-flex); no built-in line clamp; caller controls container and text.
RTL / order No custom RTL branch; caller composes icon and children in DOM order.
Loading / errors No built-in spinner/error variant; props forwarded, caller owns async lifecycle.

Copy

String i18n key Where
Send Send EmailTranscript i18n caller (Send)
Caller label Caller-owned Shared children does not localize strings.

Source

File Evidence
Shared API
Classic scope and caller class
Type role and breakpoint

AI Mode

Standard
LightDarkDesktopMobile

Ma trận variant, size và tone theo surface.

Show code
chatty-button.element.jsWrap code linesCopy
<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>
Standard
LightDarkDesktopMobile

Disabled, loading, link và nhãn truy cập của element.

Show code
chatty-button.element.jsWrap code linesCopy
<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>
Current (React), being replaced
LightDarkDesktopMobile

Các variant và size CSS kit trong một grid.

Show code
button-ai.jsxWrap code linesCopy
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>
  );
}
Current (React), being replaced
LightDarkDesktopMobile

Hover/focus, disabled và loading class.

Show code
button-ai.jsxWrap code linesCopy
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-ai-mode[data-theme]
Native button caller .aimode-continue-ai under .chatty-ai-mode

Anatomy

Part Element
1 Native button with chatty-btn + chosen variant.
2 Loading holds text in chatty-btn-label, adds chatty-btn-spinner.

Placement / order

Context Order
Continue with AI Caller wraps one native action, disabled while sending.

Props

Prop Type Values Default Notes
class string chatty-btn + accent / glass / ghost / danger classes Caller CSS kit has no React prop wrapper (chatty-btn).
disabled native boolean true / false false Accent/glass visual branches (disabled).
is-loading CSS class Caller toggle absent Caller also disables and supplies spinner (is-loading).

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
base min-height 32px 0 12px 6px 10px via radius-sm button-label Native box; no extra hit-area No size media query
md min-height 40px 0 16px 6px 14px via radius-md button-label Native box class-based
lg min-height 48px 0 24px 6px 14px via radius-md heading-large Native box class-based
block According to size According to size 6px According to size According to size width 100% class-based
Label Desktop / mobile — — — button-label 14pxDerived(14px = type(button-label, desktop, size)) / 18pxDerived(18px = type(button-label, desktop, line)) → 17pxDerived(17px = type(button-label, mobile, size)) / 24pxDerived(24px = type(button-label, mobile, line)), weight 500 No extra hit-area JS .is-mobile khi width ≤899px; hoặc media (hover: none) and (pointer: coarse), kể cả landscape >899px
Large label According to lg box — — — heading-large 17pxDerived(17px = type(heading-large, desktop, size)) / 24pxDerived(24px = type(heading-large, desktop, line)) desktop →19pxDerived(19px = type(heading-large, mobile, size)) / 26pxDerived(26px = type(heading-large, mobile, line)) mobile; weight 600 (heading-large) No extra hit-area JS .is-mobile khi width ≤899px; hoặc media (hover: none) and (pointer: coarse), kể cả landscape >899px

Tokens

Part Token Light Dark
Accent --accent Merchant --faqsBtnPopupColor, fallback #8b7be8 Same definition
On accent --on-accent Merchant label, fallback white Same definition
Hover accent --accent-deep 85% accent mixed with black Same definition
Glass fill --fill-2 rgba(20,19,24,0.07) below 900px; rgba(255,255,255,0.65) at min-width 900px rgba(255,255,255,0.1)
Glass edge --glass-edge rgba(20,19,24,0.08) rgba(255,255,255,0.12)
Text --vib-1 rgba(20,19,24,0.94) rgba(255,255,255,0.96)
Muted text --vib-3 rgba(20,19,24,0.62) rgba(255,255,255,0.62)
Hover neutral --fill-hover rgba(20,19,24,0.1) below 900px; rgba(255,255,255,0.92) at min-width 900px rgba(255,255,255,0.14)
Danger --danger #ef4444 #ef4444
Transition duration / easing --dur-2; --ease; out-emphasized 200msDerived(200ms = duration(200)); cubic-bezier(0.2,0.8,0,1); transform uses 0.18s Same
Canvas --bg-deep #f6f4f0 #131215

States

State Trigger Visual change (values) ARIA/attribute
Hover pointer accent-deep / fill-hover; danger brightness 0.95 (brightness(0.95)) Native
Pressed active not disabled scale 0.965 (scale(0.965)) No selected API
Disabled native disabled accent uses fill-2/vib-3; glass fill-1/vib-3, transparent border (--vib-3) Native disabled
Focus-visible keyboard Không có rule focus riêng trong kit; browser vẽ outline mặc định. Native
Loading is-loading + disabled opacity 0.85, cursor progress; hidden label (0.85) Caller aria-busy/name
Spinner loading child 16×16px border 2px; 0.7s linear infinite (0.7s) Caller aria-hidden

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-specific RTL handler (button).
Async ContinueWithAI resets sending in finally; its disabled action has no spinner child.
Transition timing background / border-color / color / opacity use --dur-2 and --ease; transform is 0.18s with same ease. Tokens alias --chatty-motion-duration-200 / --chatty-motion-ease-out-emphasized; inherited from consumer.

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

Standard
LightDarkDesktopMobile

Ma trận variant, size và tone theo surface.

Show code
chatty-button.element.jsWrap code linesCopy
<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>
Standard
LightDarkDesktopMobile

Disabled, loading, link và nhãn truy cập của element.

Show code
chatty-button.element.jsWrap code linesCopy
<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>
Current (React), being replaced
LightDarkDesktopMobile

Các variant và size Polaris trong một grid.

Show code
button-admin.jsxWrap code linesCopy
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 &amp; 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>
  );
}
Current (React), being replaced
LightDarkDesktopMobile

Disabled, selected, loading, disclosure và URL.

Show code
button-admin.jsxWrap code linesCopy
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 &amp; 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/polaris Global Polaris stylesheet + AppProvider context; caller .Avada-WidgetModeCard

Anatomy

Part Element
1 Native semantics through Button, text/icon/spinner slots owned by Polaris.
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/variant inputs (textAlign).
icon / disclosure IconSource / boolean Optional icon; up/down/select undefined Library chooses icon and placeholder (disclosure).
url / submit / accessibilityLabel string / boolean Navigation, submit, icon-only name undefined / false Caller-owned (url).
children ReactNode Text/icon caller content 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-width:48em; px là giá trị token Polaris
slim / medium 28px / 32px 6px / 12px 2px 8px bodySm Min box CSS min-width:48em
large 32px / 36px 6px / 12px 2px 8px bodyMd Min box CSS min-width:48em
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-relative Theo size Theo size Theo size medium 550 Native box light-mobile là theme class riêng; iOS Dynamic Type có thể đổi root
Weight semibold (primary dưới mdUp) Root-relative Theo size Theo size Theo size semibold 650 Native box light-mobile là theme class riêng; iOS Dynamic Type có thể đổi root
Weight regular (plain) Root-relative Theo size Theo size Theo size regular 450 Native box light-mobile là theme class riêng; iOS Dynamic Type có thể đổi root
light-mobile bodySm Theo size Theo size Theo size Theo size 14px / 20px Native box Theme class p-theme-light-mobile; không suy ra chỉ từ viewport
light-mobile bodyMd Theo size Theo size Theo size Theo size 16px / 24px Native box Theme class p-theme-light-mobile

Tokens

Part Token Light Dark
Radius --p-border-radius-200 8px No Dark skin
Internal spacing --p-space-050 2px No Dark skin
Text --p-color-text rgba(48,48,48,1) No Dark skin
Surface --p-color-bg-surface rgba(255,255,255,1) No Dark skin
Focus --p-color-border-focus #005bd3 No Dark skin

States

State Trigger Visual change (values) ARIA/attribute
Hover / active pointer Library swaps background / color / shadow (--pc-button-bg_hover). Native
Focus-visible keyboard 2px outline; 1px offset Native
Disabled disabled or loading No shadow, pointer-events none (pointer-events:none). Native disabled / aria-disabled
Pressed pressed true Selected background / text / shadow (--pc-button-bg_pressed). aria-pressed
Loading loading true Original label remains in layout, spinner small (Spinner). aria-busy via UnstyledButton

Behaviour

Interaction Result
Action / link URL/submit forwarded to unstyled owner (url).
Translation / wrap Text via library children; no guide-specific clamp.
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.Button.spinnerAccessibilityLabel Library spinner i18n (spinnerAccessibilityLabel).

Source

File Evidence
Product owner/import/action
Pinned dependency API
Pinned dependency API
Pinned dependency layout

Admin · Knowledge files

Current (React), being replaced
LightDarkDesktopMobile

Shared variants và sizes dưới override Knowledge files.

Show code
button.jsxWrap code linesCopy
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>
  );
}
Current (React), being replaced
LightDarkDesktopMobile

Hover, focus, disabled và aria-pressed do caller.

Show code
button.jsxWrap code linesCopy
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/chatty-ui/components/button.js .kb-ide-page > .kb-ide; inherited Polaris tokens
Style owner KnowledgeFiles.scss button .kb-ide-page .kb-ide button:not(.Polaris-Button)

Anatomy

Part Element
1 Tag native a/button chọn qua href.
2 Nội dung children; caller thêm icon/spinner.

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/border/outline none.
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/noBorder.
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 --p-color-bg-surface white No Dark skin
Text --p-color-text #303030 No Dark skin
Border --p-color-border Polaris light token No Dark skin
Focus --p-color-border-focus #005bd3 No Dark skin

States

State Trigger Visual change (values) ARIA/attribute
Hover pointer bg-surface-hover (--p-color-bg-surface-hover) Native
Disabled disabled opacity 0.48, not-allowed cursor (0.48) Native disabled
Focus-visible keyboard outline 2px, offset 2px (outline-offset) Native
Pressed caller-selected No additional selected fill; caller forwards props. Caller aria-pressed
Loading caller async Not available built-in; caller renders children. Caller aria-busy

Behaviour

Interaction Result
Surface boundary Styles target non-Polaris 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-owned 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/Space; anchor Enter; focus theo popup 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/ghost/iconOnly Light 17.85:1Measured(#0f172a / #ffffff = 17.85:1); action Dark override 13.20:1Measured(#303030 / #ffffff = 13.20:1)
Classic loading Spinner thay label Nút disabled Không aria-busy 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-visible riêng Caller tự cung cấp busy status danger 3.76:1Measured(#ffffff / #ef4444 = 3.76:1); glass --vib-1 trên composite --fill-2 + --bg-deep: Light desktop 15.50:1Measured(rgba(20,19,24,0.94) / rgba(255,255,255,0.65) over #f6f4f0 = 15.50:1), mobile 12.85:1Measured(rgba(20,19,24,0.94) / rgba(20,19,24,0.07) over #f6f4f0 = 12.85:1), Dark 13.32:1Measured(rgba(255,255,255,0.96) / rgba(255,255,255,0.1) over #131215 = 13.32:1); ghost Light 5.00:1Measured(rgba(20,19,24,0.62) / #f6f4f0 = 5.00:1), Dark 7.59:1Measured(rgba(255,255,255,0.62) / #131215 = 7.59:1)
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-owned Các button variant trên Light 13.20:1Measured(#303030 / #ffffff = 13.20:1); anchor giữ shared style

Target