On this page

Composer / input

Input một dòng của Classic: ba size, trạng thái error và disabled, tên truy cập do caller nối.

Copy page as MarkdownRead Markdown ↗

Key rules

  • Classic: dùng Input với size small, medium hoặc large; chiều cao lấy từ chatty:h-8, chatty:h-10, chatty:h-12.
  • Classic: Input không render label và không render message lỗi; caller nối htmlFor/id và aria-describedby.
  • Classic: error chỉ đổi viền sang chatty:border-destructive; caller thêm aria-invalid và thông báo.
  • Classic: PopupBody vẽ focus-visible cho input bằng outline 2px; chữ input giữ role mobile 18px; tối đa 500px có sàn 16px.
  • Input là field một giá trị; vùng soạn tin nhiều dòng không dùng component này.
On this page

Use when / Avoid

Dùng cho dữ liệu một dòng như email hoặc tên. Không dùng placeholder làm label duy nhất. Vùng soạn tin và textarea là build riêng, không phải Input.

Use instead

Component Use when
Input Field một dòng; Classic FormField dùng cho trường form.
textarea Field nhiều dòng; FormField dùng native textarea riêng.

Live preview

Classic

LightDarkDesktopMobile

Input thật: large, error, read-only và disabled.

Show code
composer-input.jsxWrap code linesCopy
import React from 'react';
import {Input} from '@avada/chatty-ui/components/input.js';

export function Fields() {
  return (
    <div>
      <label htmlFor="small-email">Small</label>
      <Input id="small-email" size="small" defaultValue="customer@example.com" />
      <label htmlFor="medium-email">Medium</label>
      <Input id="medium-email" size="medium" defaultValue="customer@example.com" />
      <label htmlFor="email">Large</label>
      <Input id="email" type="email" size="large" defaultValue="customer@example.com" />
      <label htmlFor="invalid-email">Email with error</label>
      <Input
        id="invalid-email"
        error
        aria-invalid="true"
        aria-describedby="email-error"
        defaultValue="invalid"
      />
      <p id="email-error">Enter a valid email address.</p>
      <label htmlFor="locked-email">Read-only email</label>
      <Input id="locked-email" readOnly value="customer@example.com" />
      <label htmlFor="disabled-email">Disabled email</label>
      <Input id="disabled-email" disabled value="customer@example.com" />
    </div>
  );
}

Import / element

Component / element Import / file Scope root
Input @avada/chatty-ui .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup

Anatomy

Part Element
1 Native input; type mặc định là text.
2 Label và message lỗi do caller đặt ngoài component.

Placement / order

Context Order
Form chiến dịch FormField render Input với placeholder; label không nằm trong Input.

Props

Prop Type Values Default Notes
size string small, medium, large medium Chọn height và padding ngang.
type string HTML input type text Chuyển vào native input.
error boolean true, false false Đổi viền sang destructive.
disabled boolean true, false false Thêm chatty:bg-muted khi disabled.
className string CSS classes undefined Gộp cuối danh sách class.
props attributes Native attrs, handlers, ARIA Caller Spread vào input; caller đặt tên truy cập.

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
small 32pxDerived(32px = h-8 × 4px) 12pxDerived(12px = px-3 × 4px) Không khai báo 8px (chatty:rounded-md) input-value 15pxDerived(15px = type(input-value, desktop, size)) / 22pxDerived(22px = type(input-value, desktop, line)); weight 400 Native box Mobile role 18pxDerived(18px = type(input-value, mobile, size)) / 24pxDerived(24px = type(input-value, mobile, line)); tối đa 500px có sàn 16px, không giảm role
medium 40pxDerived(40px = h-10 × 4px) 12pxDerived(12px = px-3 × 4px) Không khai báo 8px (chatty:rounded-md) input-value 15pxDerived(15px = type(input-value, desktop, size)) / 22pxDerived(22px = type(input-value, desktop, line)); weight 400 Native box Mobile role 18pxDerived(18px = type(input-value, mobile, size)) / 24pxDerived(24px = type(input-value, mobile, line)); tối đa 500px có sàn 16px, không giảm role
large 48pxDerived(48px = h-12 × 4px) 16pxDerived(16px = px-4 × 4px) Không khai báo 8px (chatty:rounded-md) input-value 15pxDerived(15px = type(input-value, desktop, size)) / 22pxDerived(22px = type(input-value, desktop, line)); weight 400 Native box Mobile role 18pxDerived(18px = type(input-value, mobile, size)) / 24pxDerived(24px = type(input-value, mobile, line)); tối đa 500px có sàn 16px, không giảm role

Tokens

Part Token Light Dark
Background --chatty-background #ffffff Merchant --faqsBgColor
Text --chatty-foreground #0f172a Merchant --faqsTextColor
Placeholder --chatty-muted-foreground #64748b Merchant --faqsTextColorSecondary
Border --chatty-border #e2e8f0 #e2e8f0
Error border --chatty-destructive #ef4444 #ef4444
Disabled fill --chatty-muted #f1f5f9 #f1f5f9
Focus ring --chatty-ring Merchant --faqsTextColor, fallback #303030 Merchant --faqsTextColor, fallback #eee

States

State Trigger Visual change (values) ARIA/attribute
Default render chatty:border-border, chatty:bg-background Không thêm ARIA
Hover pointer Nền giữ --chatty-background; Input không có viền hover riêng Native
Focus-visible keyboard outline 2px solid --chatty-ring, offset 2px Native focus
Error error true chatty:border-destructive Caller đặt aria-invalid
Disabled disabled chatty:disabled:opacity-50, chatty:disabled:cursor-not-allowed, chatty:bg-muted Native disabled
Read-only readOnly attribute Không có style riêng; giá trị vẫn đọc và chọn được Native readonly

Behaviour

Interaction Result
Keyboard Native input nhận gõ và Tab; disabled bị loại khỏi Tab.
Màn hình hẹp Tối đa 500px: dùng max(16px, var(--chatty-type-input-value-size, 16px)) để giữ role và tránh iOS phóng to.
Lỗi error chỉ đổi viền; message và ARIA do caller cấp.

Copy

String i18n key Where
Placeholder Caller-owned placeholder truyền từ FormField
Label / lỗi Caller-owned Ngoài component

Source

File Evidence
API và element
Token và focus Classic
Caller

Do / Don't

Accessibility

Surface Role / name Keyboard / focus Live region Contrast pair / ratio
Classic input native; tên từ label của caller Tab vào field; outline 2px offset 2px khi focus-visible Caller-owned Text 17.85:1Measured(#0f172a / #ffffff = 17.85:1); border 1.23:1Measured(#e2e8f0 / #ffffff = 1.23:1)

Target