Skip to content

Button ​

Nút bấm cho hành động chính trong UI Soft Periwinkle. Dùng color cho tông trạng thái (mặc định primary) và variant cho kiểu hiển thị (solid, secondary, outline, ghost, link).

ts
import { Button } from "@minap/ui";

Examples ​

Các mẫu theo use case thường gặp. Preview luôn sẵn; chọn View code khi cần xem hoặc copy mã nguồn.

Basic ​

Primary mặc định — điểm bắt đầu cho CTA chính.

tsx
import { Button } from "@minap/ui";

export function Example() {
  return <Button>Continue</Button>;
}

Variants ​

Toàn bộ variant mà Button hỗ trợ.

tsx
import { Button } from "@minap/ui";

export function Example() {
  return (
    <div className="flex flex-wrap gap-2">
      <Button variant="solid">solid</Button>
      <Button variant="secondary">secondary</Button>
      <Button variant="outline">outline</Button>
      <Button variant="ghost">ghost</Button>
      <Button variant="link">link</Button>
    </div>
  );
}

Colors ​

Các color (không truyền = primary) và ví dụ kết hợp với variant.

tsx
import { Button } from "@minap/ui";

export function Example() {
  return (
    <div className="flex flex-wrap gap-2">
      <Button>primary</Button>
      <Button color="success">success</Button>
      <Button color="warning">warning</Button>
      <Button color="destructive">destructive</Button>
      <Button color="info">info</Button>
      <Button color="destructive" variant="outline">
        destructive outline
      </Button>
    </div>
  );
}

Sizes ​

sm, default (chiều cao touch ~44px), lg, và icon.

tsx
import { Button } from "@minap/ui";

export function Example() {
  return (
    <div className="flex flex-wrap items-center gap-2">
      <Button size="sm">sm</Button>
      <Button size="default">default (~44px)</Button>
      <Button size="lg">lg</Button>
      <Button size="icon" aria-label="Star">
        ★
      </Button>
    </div>
  );
}

States ​

Disabled và trạng thái busy / loading — nhấn Controlled save trên Preview để xem.

tsx
import { useState } from "react";
import { Button } from "@minap/ui";

export function Example() {
  const [pending, setPending] = useState(false);

  return (
    <div className="flex flex-wrap items-center gap-2">
      <Button disabled>disabled</Button>
      <Button
        aria-busy={pending || undefined}
        disabled={pending}
        onClick={() => {
          setPending(true);
          window.setTimeout(() => setPending(false), 900);
        }}
      >
        {pending ? "Saving…" : "Controlled save"}
      </Button>
    </div>
  );
}

Composition ​

Kết hợp Button với Badge trong một cụm hành động / trạng thái.

tsx
import { Badge, Button } from "@minap/ui";

export function Example() {
  return (
    <div className="flex flex-wrap items-center gap-2">
      <Button size="sm">Lưu</Button>
      <Badge color="success">Sẵn sàng</Badge>
    </div>
  );
}

Props / API ​

Prop / APITypeDefaultNotes
color"primary" | "success" | "warning" | "destructive" | "info""primary"Bỏ qua prop → primary. Không có color="default".
variant"solid" | "outline" | "ghost" | "link" | "secondary""solid"Kiểu hiển thị (chrome)
size"default" | "sm" | "lg" | "icon""default"default dùng chiều cao touch ~44px
asChildbooleanfalseRadix Slot — render qua phần tử con
pressFeedbackbooleantruePress scale + overlay (--press-*). false cho field-like (DatePicker) / ô Calendar
classNamestring—Tailwind / class bổ sung

Behavior ​

  • Focus ring rõ khi điều khiển bằng bàn phím hoặc tap
  • Press feedback mặc định (token --press-scale / --press-shadow); tắt bằng pressFeedback={false}
  • Tối ưu cảm ứng trên Mobile-First / WebView
  • Chuyển tiếp các thuộc tính native của <button> (ví dụ type, disabled, aria-*)

MINAP UI — Soft Periwinkle light, Mobile-First