Status Pill
WhereUIป้ายสถานะทรงแคปซูล ใช้คู่สีพื้นอ่อน -soft กับตัวอักษรสีเดียวกัน มีจุดสีนำหน้าข้อความได้
ร่างส่งแล้วรอตรวจสอบอนุมัติไม่อนุมัติ
ติดตั้ง
Terminal
pnpm dlx shadcn@latest add @whereui/status-pillต้องผูก registry และติดตั้ง @whereui/theme นำหน้าเสมอเมื่อติดตั้งครั้งแรก
การใช้งาน
import { StatusPill } from "@/components/ui/status-pill"<StatusPill variant="success">อนุมัติ</StatusPill>ตัวอย่างเพิ่มเติม
แบบไม่มีจุดนำหน้า
ปิดรับสมัครกำลังพิจารณาผ่านการประเมิน
Props
| prop | type | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| variant | "neutral" | "info" | "success" | "warning" | "destructive" | "neutral" | neutral ใช้ muted · ตัวอื่นใช้คู่สี -soft เช่น bg-success-soft text-success |
| dot | boolean | true | จุดสีนำหน้าข้อความ (สีเดียวกับตัวอักษร) |
ข้อควรรู้
- ใช้แทน Badge เมื่อต้องการสื่อสถานะ — Badge เหมาะกับตัวเลข/ป้ายกำกับทั่วไป
ซอร์สโค้ด
components/ui/status-pill.tsx
import * as React from "react"import { cva, type VariantProps } from "class-variance-authority"import { cn } from "cn"const statusPillVariants = cva( "inline-flex h-5 w-fit shrink-0 items-center gap-1.5 rounded-4xl px-2 text-xs font-medium whitespace-nowrap", { variants: { variant: { neutral: "bg-muted text-muted-foreground", info: "bg-info-soft text-info", success: "bg-success-soft text-success", warning: "bg-warning-soft text-warning", destructive: "bg-destructive-soft text-destructive", }, }, defaultVariants: { variant: "neutral", }, })function StatusPill({ className, variant, dot = true, children, ...props}: React.ComponentProps<"span"> & VariantProps<typeof statusPillVariants> & { /** แสดงจุดสีนำหน้าข้อความ */ dot?: boolean }) { return ( <span data-slot="status-pill" data-variant={variant} className={cn(statusPillVariants({ variant }), className)} {...props} > {dot ? ( <span data-slot="status-pill-dot" aria-hidden="true" className="size-1.5 shrink-0 rounded-full bg-current" /> ) : null} {children} </span> )}export { StatusPill, statusPillVariants }