ป้ายสถานะ
Badge
Reports a state and can't be pressed. Always carries text, so colour is never the only signal.
ใช้แสดงสถานะของรายการ เช่น ในตารางหรือหัวหน้ารายละเอียด ป้ายกดไม่ได้ ถ้าผู้ใช้ต้องกดเพื่อเลือกหรือกรอง ใช้ Chip
import { Badge } from "@bsru/ui";ตัวอย่าง
ป้ายพร้อมไอคอน
ส่ง tone และข้อความ ไอคอนช่วยให้อ่านสถานะได้โดยไม่ต้องพึ่งสี
อนุมัติแล้ว
<Badge tone="approved" icon={Check}>อนุมัติแล้ว</Badge>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | "approved" | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | The state, which sets the colour. |
| icon | Check | LucideIcon | A lucide icon shown before the text. |
tone="draft"
สำหรับสถานะ ร่าง
ร่าง
<Badge tone="draft" icon={Pencil}>ร่าง</Badge>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | "draft" | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | The state, which sets the colour. |
| icon | Pencil | LucideIcon | A lucide icon shown before the text. |
tone="pending"
สำหรับสถานะ รออนุมัติ
รออนุมัติ
<Badge tone="pending" icon={Clock}>รออนุมัติ</Badge>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | "pending" | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | The state, which sets the colour. |
| icon | Clock | LucideIcon | A lucide icon shown before the text. |
tone="paid"
สำหรับสถานะ ชำระแล้ว
ชำระแล้ว
<Badge tone="paid" icon={CircleCheck}>ชำระแล้ว</Badge>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | "paid" | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | The state, which sets the colour. |
| icon | CircleCheck | LucideIcon | A lucide icon shown before the text. |
tone="request"
สำหรับสถานะ คำขอ รอยืนยันในระบบ ERP
คำขอ รอยืนยันในระบบ ERP
<Badge tone="request" icon={Bot}>คำขอ รอยืนยันในระบบ ERP</Badge>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | "request" | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | The state, which sets the colour. |
| icon | Bot | LucideIcon | A lucide icon shown before the text. |
tone="rejected"
สำหรับสถานะ ไม่อนุมัติ
ไม่อนุมัติ
<Badge tone="rejected" icon={X}>ไม่อนุมัติ</Badge>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | "rejected" | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | The state, which sets the colour. |
| icon | X | LucideIcon | A lucide icon shown before the text. |
ป้ายเส้นขอบ
tone line ใช้กับข้อมูลประกอบที่ไม่ใช่สถานะ เช่น ปีงบประมาณ
ปีงบ 2570
<Badge tone="line">ปีงบ 2570</Badge>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | "line" | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | The state, which sets the colour. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| tone* จำเป็น | BadgeTone ค่าที่ใช้ได้: "draft""pending""approved""paid""request""rejected""line" | — | The state, which sets the colour. |
| icon | LucideIcon | — | A lucide icon shown before the text. |
| children* จำเป็น | ReactNode | — | The text, already in the screen language. |
ชนิดข้อมูล
BadgeTone
The state a badge reports. Each one has its own colour. line is for facts that aren't a state.
type BadgeTone = "draft" | "pending" | "approved" | "paid" | "request" | "rejected" | "line";ข้อควรปฏิบัติ
- ข้อความในป้ายต้องมีเสมอ และส่งมาในภาษาของหน้าจอ
- ใช้ tone ตามความหมายของสถานะ ไม่ใช่ตามสีที่ชอบ
ซอร์สโค้ด: ui/src/status.tsx