ขั้นตอน
Steps
The steps of a process, with the finished ones ticked. `current` is the index of the step in progress. Leave it out for an outline of a process that isn't running, such as the stages of a flow on a card: every step shows its number. Each step can carry a description and its own content, such as a form or a file upload, for a step-by-step task.
ใช้แสดงว่ารายการอยู่ขั้นไหนของกระบวนงานที่มีลำดับตายตัว เช่น จากคำขอถึงเบิกจ่าย หรือขั้นของฟอร์มหลายหน้า ส่งรายการขั้นและลำดับของขั้นปัจจุบัน ถ้าต้องบอกว่าใครอนุมัติและเมื่อไร ใช้ ApprovalChain ถ้าแค่บอกสถานะของรายการ ใช้ Badge ถ้าผู้ใช้ต้องกดสลับส่วน ใช้ Tabs
import { Steps } from "@bsru/ui";ตัวอย่าง
อยู่ระหว่างกระบวนงาน
current เป็นลำดับเริ่มจาก 0 ขั้นก่อนหน้ามีเครื่องหมายถูก ขั้นปัจจุบันเป็นตัวหนา
- คำขอ
- อนุมัติ
- 3ใบสั่งซื้อ
- 4ตรวจรับ
- 5เบิกจ่าย
<Steps
current={2}
steps={[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| current | 2 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 5 รายการ[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
] | readonly Step[] | The steps, in order. |
ขั้นแรก
- 1คำขอ
- 2อนุมัติ
- 3ใบสั่งซื้อ
- 4ตรวจรับ
- 5เบิกจ่าย
<Steps
current={0}
steps={[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| current | 0 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 5 รายการ[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
] | readonly Step[] | The steps, in order. |
เสร็จทุกขั้น
ส่ง current เท่ากับจำนวนขั้น เพื่อให้ทุกขั้นมีเครื่องหมายถูก
- คำขอ
- อนุมัติ
- ใบสั่งซื้อ
- ตรวจรับ
- เบิกจ่าย
<Steps
current={5}
steps={[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| current | 5 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 5 รายการ[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
] | readonly Step[] | The steps, in order. |
ลำดับขั้นในแนวตั้ง
orientation="vertical" เรียงขั้นจากบนลงล่าง ป้ายอยู่ข้างวงกลมและขึ้นบรรทัดใหม่ได้ จึงใส่ในการ์ดหรือคอลัมน์แคบได้ทุกจำนวนขั้น ไม่ส่ง current เพื่อแสดงลำดับขั้นของกระบวนงานที่ไม่ได้ดำเนินอยู่ ทุกขั้นแสดงหมายเลข ไม่มีขั้นใดเป็นขั้นปัจจุบัน
- 1ตั้งหนี้ค่าหอพัก
- 2ชำระด้วย QR
- 3ใบเสร็จรับเงินอิเล็กทรอนิกส์
- 4ตัดหนี้อัตโนมัติ
<Steps
orientation="vertical"
steps={[
{ label: "ตั้งหนี้ค่าหอพัก" },
{ label: "ชำระด้วย QR" },
{ label: "ใบเสร็จรับเงินอิเล็กทรอนิกส์" },
{ label: "ตัดหนี้อัตโนมัติ" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| orientation | "vertical" | StepsOrientation ค่าที่ใช้ได้: "horizontal""vertical" | horizontal, the default, puts the steps in a row, with each label under its circle; on a narrow screen the row scrolls sideways. vertical stacks them, with each label beside its circle and a line joining the circles, so long labels wrap and any number of steps fits a card or a narrow column. |
| steps* จำเป็น | รายการ 4 รายการ[
{ label: "ตั้งหนี้ค่าหอพัก" },
{ label: "ชำระด้วย QR" },
{ label: "ใบเสร็จรับเงินอิเล็กทรอนิกส์" },
{ label: "ตัดหนี้อัตโนมัติ" },
] | readonly Step[] | The steps, in order. |
แนวตั้ง อยู่ระหว่างกระบวนงาน
current ทำงานเหมือนแนวนอน เส้นที่เชื่อมขั้นที่เสร็จแล้วเป็นสีหลักของแอป
- ตั้งหนี้ค่าหอพัก
- ชำระด้วย QR
- 3ใบเสร็จรับเงินอิเล็กทรอนิกส์
- 4ตัดหนี้อัตโนมัติ
<Steps
orientation="vertical"
current={2}
steps={[
{ label: "ตั้งหนี้ค่าหอพัก" },
{ label: "ชำระด้วย QR" },
{ label: "ใบเสร็จรับเงินอิเล็กทรอนิกส์" },
{ label: "ตัดหนี้อัตโนมัติ" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| orientation | "vertical" | StepsOrientation ค่าที่ใช้ได้: "horizontal""vertical" | horizontal, the default, puts the steps in a row, with each label under its circle; on a narrow screen the row scrolls sideways. vertical stacks them, with each label beside its circle and a line joining the circles, so long labels wrap and any number of steps fits a card or a narrow column. |
| current | 2 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 4 รายการ[
{ label: "ตั้งหนี้ค่าหอพัก" },
{ label: "ชำระด้วย QR" },
{ label: "ใบเสร็จรับเงินอิเล็กทรอนิกส์" },
{ label: "ตัดหนี้อัตโนมัติ" },
] | readonly Step[] | The steps, in order. |
บนการ์ดเด่น
บน Card แบบ feature ขั้นเปลี่ยนเป็นสีขาวบนพื้นสีหลัก ขั้นที่เสร็จเป็นวงกลมสีขาวมีเครื่องหมายถูก ขั้นปัจจุบันเป็นวงขาวทึบ ขั้นที่ยังไม่ถึงเป็นวงขาวโปร่ง หน้าจอไม่ต้องส่งอะไรเพิ่ม
ค่าหอพัก
4 ขั้น
- ตั้งหนี้ค่าหอพัก
- ชำระด้วย QR
- 3ใบเสร็จรับเงินอิเล็กทรอนิกส์
- 4ตัดหนี้อัตโนมัติ
<Card tone="feature" title="ค่าหอพัก" description="4 ขั้น" icon={BedDouble}>
<Steps orientation="vertical" current={2} steps={steps} />
</Card>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| orientation | "vertical" | StepsOrientation ค่าที่ใช้ได้: "horizontal""vertical" | horizontal, the default, puts the steps in a row, with each label under its circle; on a narrow screen the row scrolls sideways. vertical stacks them, with each label beside its circle and a line joining the circles, so long labels wrap and any number of steps fits a card or a narrow column. |
| current | 2 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 4 รายการ[
{ label: "ตั้งหนี้ค่าหอพัก" },
{ label: "ชำระด้วย QR" },
{ label: "ใบเสร็จรับเงินอิเล็กทรอนิกส์" },
{ label: "ตัดหนี้อัตโนมัติ" },
] | readonly Step[] | The steps, in order. |
คำอธิบายใต้แต่ละขั้น
description แสดงใต้ป้ายของขั้น เช่น ใครทำ ต้องใช้อะไร หรือเสร็จเมื่อไร ทั้งแนวตั้งและแนวนอน
- คำขอนายทดสอบ มีสุข ส่งเมื่อ 1 ต.ค. 2569
- อนุมัติหัวหน้าหน่วยงานอนุมัติเมื่อ 2 ต.ค. 2569
- 3ใบสั่งซื้อเจ้าหน้าที่พัสดุกำลังออกใบสั่งซื้อ
- 4ตรวจรับคณะกรรมการตรวจรับพัสดุ
- 5เบิกจ่ายการเงินจ่ายเงินให้ผู้ขาย
<Steps
orientation="vertical"
current={2}
steps={[
{
label: "คำขอ",
description: "นายทดสอบ มีสุข ส่งเมื่อ 1 ต.ค. 2569",
},
{
label: "อนุมัติ",
description: "หัวหน้าหน่วยงานอนุมัติเมื่อ 2 ต.ค. 2569",
},
{
label: "ใบสั่งซื้อ",
description: "เจ้าหน้าที่พัสดุกำลังออกใบสั่งซื้อ",
},
{ label: "ตรวจรับ", description: "คณะกรรมการตรวจรับพัสดุ" },
{ label: "เบิกจ่าย", description: "การเงินจ่ายเงินให้ผู้ขาย" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| orientation | "vertical" | StepsOrientation ค่าที่ใช้ได้: "horizontal""vertical" | horizontal, the default, puts the steps in a row, with each label under its circle; on a narrow screen the row scrolls sideways. vertical stacks them, with each label beside its circle and a line joining the circles, so long labels wrap and any number of steps fits a card or a narrow column. |
| current | 2 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 5 รายการ[
{ label: "คำขอ", description: "นายทดสอบ มีสุข ส่งเมื่อ 1 ต.ค. 2569" },
{
label: "อนุมัติ",
description: "หัวหน้าหน่วยงานอนุมัติเมื่อ 2 ต.ค. 2569",
},
{
label: "ใบสั่งซื้อ",
description: "เจ้าหน้าที่พัสดุกำลังออกใบสั่งซื้อ",
},
{ label: "ตรวจรับ", description: "คณะกรรมการตรวจรับพัสดุ" },
{ label: "เบิกจ่าย", description: "การเงินจ่ายเงินให้ผู้ขาย" },
] | readonly Step[] | The steps, in order. |
ฟอร์มในแต่ละขั้น
content เป็นพื้นที่ของขั้นนั้นเอง ใต้ป้ายและคำอธิบาย ใส่ส่วนประกอบใดก็ได้ เช่น TextInput FileDrop และปุ่ม แนวตั้งแสดง content ของทุกขั้นที่ส่งมา จึงส่ง content เฉพาะขั้นปัจจุบันเมื่อทำทีละขั้น ลองกดถัดไปและย้อนกลับ
- ผู้ยื่นคำขอนายทดสอบ มีสุข หน่วยงาน ก
- 2รายละเอียดคำขอบอกว่าจะซื้อหรือจ้างอะไร
- 3แนบเอกสารใบเสนอราคาและรายละเอียดคุณลักษณะ
- 4ส่งคำขอตรวจทานแล้วส่ง
const [step, setStep] = useState(1);
// Only the current step gets content: its form, then Back and Next.
const steps: Step[] = [
{ label: "ผู้ยื่นคำขอ", description: "นายทดสอบ มีสุข หน่วยงาน ก" },
{
label: "รายละเอียดคำขอ",
description: "บอกว่าจะซื้อหรือจ้างอะไร",
content: step === 1 && (
<div className="flex flex-col gap-3">
<TextInput label="เรื่อง" value={subject} onValueChange={setSubject} required />
<StepNav step={step} onStep={setStep} />
</div>
),
},
{
label: "แนบเอกสาร",
description: "ใบเสนอราคาและรายละเอียดคุณลักษณะ",
content: step === 2 && (
<FileDrop title="ลากไฟล์มาวาง หรือกดเพื่อเลือก" hint="PDF ไม่เกิน 10 MB" multiple accept=".pdf" value={files} onFiles={setFiles} />
),
},
{ label: "ส่งคำขอ", description: "ตรวจทานแล้วส่ง" },
];
<Steps orientation="vertical" current={step} steps={steps} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| orientation | "vertical" | StepsOrientation ค่าที่ใช้ได้: "horizontal""vertical" | horizontal, the default, puts the steps in a row, with each label under its circle; on a narrow screen the row scrolls sideways. vertical stacks them, with each label beside its circle and a line joining the circles, so long labels wrap and any number of steps fits a card or a narrow column. |
| current | 1 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 4 รายการ[
{ label: "ผู้ยื่นคำขอ", description: "นายทดสอบ มีสุข หน่วยงาน ก" },
{
label: "รายละเอียดคำขอ",
description: "บอกว่าจะซื้อหรือจ้างอะไร",
content: "<TextInput /> <Button />",
},
{
label: "แนบเอกสาร",
description: "ใบเสนอราคาและรายละเอียดคุณลักษณะ",
},
{ label: "ส่งคำขอ", description: "ตรวจทานแล้วส่ง" },
] | readonly Step[] | The steps, in order. |
Badge ชิป และปุ่มในขั้น
ทุกขั้นแสดง content ของตัวเองพร้อมกันได้ เช่น Badge บอกสถานะ ชิปให้เลือก และปุ่มของขั้นสุดท้าย
- 1สถานะงบประมาณตรวจจากระบบงบประมาณวงเงินพอ คงเหลือ 4,750,000.00 บาท
- 2ประเภทของที่จะซื้อเลือกได้มากกว่าหนึ่งประเภท
- 3ขั้นตอนถัดไป
const steps: Step[] = [
{
label: "สถานะงบประมาณ",
description: "ตรวจจากระบบงบประมาณ",
content: <Badge tone="approved" icon={Check}>วงเงินพอ คงเหลือ 4,750,000.00 บาท</Badge>,
},
{
label: "ประเภทของที่จะซื้อ",
description: "เลือกได้มากกว่าหนึ่งประเภท",
content: (
<div className="flex flex-wrap gap-2">
{kinds.map((k) => (
<Chip key={k.value} pressed={chosen.includes(k.value)} onPressedChange={(on) => choose(k.value, on)}>
{k.label}
</Chip>
))}
</div>
),
},
{
label: "ขั้นตอนถัดไป",
content: (
<div className="flex flex-wrap gap-2">
<Button label="สร้างคำขอ" tone="primary" size="sm" onClick={createRequest} />
<Button label="บันทึกร่าง" size="sm" onClick={saveDraft} />
</div>
),
},
];
<Steps orientation="vertical" steps={steps} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| orientation | "vertical" | StepsOrientation ค่าที่ใช้ได้: "horizontal""vertical" | horizontal, the default, puts the steps in a row, with each label under its circle; on a narrow screen the row scrolls sideways. vertical stacks them, with each label beside its circle and a line joining the circles, so long labels wrap and any number of steps fits a card or a narrow column. |
| steps* จำเป็น | รายการ 3 รายการ[
{
label: "สถานะงบประมาณ",
description: "ตรวจจากระบบงบประมาณ",
content: "<Badge />",
},
{
label: "ประเภทของที่จะซื้อ",
description: "เลือกได้มากกว่าหนึ่งประเภท",
content: "<Chip /> …",
},
{ label: "ขั้นตอนถัดไป", content: "<Button /> <Button />" },
] | readonly Step[] | The steps, in order. |
แนวนอน เนื้อหาของขั้นปัจจุบันอยู่ใต้แถว
แถวไม่มีที่ให้เนื้อหาของทุกขั้น จึงแสดงเฉพาะ content ของขั้นปัจจุบันใต้แถว ส่ง content ให้ทุกขั้นได้ แล้วเปลี่ยน current เพื่อเลื่อนขั้น
- 1ข้อมูลผู้ขาย
- 2รายการสินค้า
- 3เงื่อนไขการส่งมอบ
ตัวอย่างนี้ไม่บันทึกข้อมูล
const steps: Step[] = forms.map((form, i) => ({
label: form.label,
description: i < step ? "เสร็จแล้ว" : undefined,
content: <VendorStep form={form} onBack={() => setStep(i - 1)} onNext={() => setStep(i + 1)} />,
}));
<Steps current={step} steps={steps} />| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| current | 0 | number | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| steps* จำเป็น | รายการ 3 รายการ[
{ label: "ข้อมูลผู้ขาย", content: "<TextInput /> <Button />" },
{ label: "รายการสินค้า", content: "<TextInput /> <Button />" },
{ label: "เงื่อนไขการส่งมอบ", content: "<TextInput /> <Button />" },
] | readonly Step[] | The steps, in order. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| steps* จำเป็น | readonly Step[] | — | The steps, in order. |
| current | number | — | The index of the step in progress, from 0. Steps before it are ticked, and this one is bold with aria-current="step". Use steps.length when all are done. Leave it out for a plain outline: no step is ticked, bold or current. |
| orientation | StepsOrientation ค่าที่ใช้ได้: "horizontal""vertical" | "horizontal" | horizontal, the default, puts the steps in a row, with each label under its circle; on a narrow screen the row scrolls sideways. vertical stacks them, with each label beside its circle and a line joining the circles, so long labels wrap and any number of steps fits a card or a narrow column. |
| className | string | — | Extra classes for the list, such as spacing. |
ชนิดข้อมูล
Step
One step of a process.
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| label* จำเป็น | ReactNode | — | The step's name, already in the screen language. |
| description | ReactNode | — | A line or two under the label, such as who acts, what the step needs, or when it was done. |
| content | ReactNode | — | The step's own area, under its label and description: any of the library's components, such as a form, a FileDrop, Chips, a Badge or Buttons. Vertical steps show every step's content. A row has no room for it, so horizontal steps show only the current step's content, under the row. |
StepsOrientation
How Steps lays out: a row with each label under its circle, or a column with each label beside its circle.
type StepsOrientation = "horizontal" | "vertical";ข้อควรปฏิบัติ
- ขั้นปัจจุบันมี aria-current="step" ส่ง label ในภาษาของหน้าจอ และสั้นพอให้อยู่ใต้วงกลม
- เครื่องหมายถูกของขั้นที่เสร็จเป็นไอคอนตกแต่ง โปรแกรมอ่านหน้าจอไม่ได้ยินว่าเสร็จแล้ว บอกสถานะของรายการเป็นข้อความด้วย เช่น Badge
- วงกลมและป้ายของขั้นกดไม่ได้ ถ้าให้ย้อนกลับไปแก้ขั้นก่อนหน้า ใส่ปุ่มย้อนกลับไว้ใน content ของขั้น
- content ใส่ส่วนประกอบของไลบรารีเท่านั้น เช่น ฟอร์ม FileDrop Chip Badge และ Button จัดวางด้วย flex หรือ grid ได้ แต่ไม่ใส่สีหรือขอบเอง
- ในงานที่ทำทีละขั้น ส่ง content ให้ขั้นปัจจุบันเท่านั้น และให้คำอธิบายของขั้นที่เสร็จแล้วสรุปสิ่งที่กรอกไว้
- บนจอแคบ รายการแนวนอนเลื่อนไปด้านข้างได้ ใช้ไม่เกินประมาณ 6 ขั้น ถ้ามีมากกว่านั้น ป้ายยาว หรืออยู่ในการ์ด ใช้ orientation="vertical"
ซอร์สโค้ด: ui/src/progress.tsx