หน้าตัวอย่าง
ภาพรวม
ใช้เป็นหน้าแรกหลังเข้าสู่ระบบ เพื่อตอบว่าตอนนี้เป็นอย่างไร และมีอะไรรอให้ทำ ตัวเลขสำคัญอยู่บนสุด กราฟอยู่ถัดลงมา และรายการที่รอการทำงานอยู่ล่างสุด ถ้าต้องวิเคราะห์ลึกหรือกรองข้อมูลหลายแบบ ทำเป็นหน้ารายงานแยก
คอมโพเนนต์ที่ใช้
- KpiTilesA row of key figures, each with its change and a trend line, in one band or as a card each.
- BarChartCompares groups as grouped, stacked or 100% bars, with a switch between them.
- GaugeChartOne percentage against a target, as a thick half ring: the result in the brand colour, the stretch still to go to the target in its darkest shade, and the rest past the target in diagonal lines.
- DonutChartWhat share each part is, as a donut with the total in the middle.
- DataTableA complete data table from columns and rows: a filter bar with search, filter chips, sortable headings, paging, row selection with bulk actions, a total row, and the loading, error, first-use and no-results states.
- PageHeaderThe top of a page: a short line saying where it belongs, the page's title as its one level 1 heading, a sentence on what it's for, and the page's actions.
- CardA card for one piece of a page, such as a dashboard section: a header with a title, a line under it, an icon and an action in its corner; the content; and a footer for actions or a note.
- AppShellThe application frame: the left menu, which collapses to icons on wide screens and slides in on phones, and the top bar with the breadcrumb, global search, language switch, notifications and account menu.
import { KpiTiles, BarChart, GaugeChart, DonutChart, DataTable, PageHeader, Card, AppShell } from "@bsru/ui";กฎของหน้านี้
ลำดับของหน้า
- PageHeader ก่อน พร้อมปุ่มหลักไม่เกินหนึ่งปุ่มและปุ่มรองหนึ่งปุ่ม
- KpiTiles แบบการ์ด ไม่เกินสี่ตัว เลือกตัวเลขที่ผู้ใช้ต้องตัดสินใจจากมัน และเน้นตัวที่สำคัญที่สุดหนึ่งตัวด้วย highlight
- ทุกส่วนอยู่บน Card ส่วนหัวมีหัวข้อ ไอคอน และปุ่มเดียว เช่น ดูทั้งหมด ส่วนท้ายมีหมายเหตุหรือปุ่มของการ์ด การ์ด tone feature มีไม่เกินหนึ่งใบ เช่น การประชุมครั้งถัดไป กราฟและตาราง วางเป็นตารางสามคอลัมน์บนจอกว้าง กราฟหลักกว้างสองคอลัมน์ บนมือถือเรียงเป็นคอลัมน์เดียว
- รายการที่รอการทำงานอยู่ล่างสุด เป็น DataTable สั้น ๆ ใน DashedContainer บนการ์ด ที่เปิดไปหน้ารายการเต็มได้
กราฟ
- กราฟหนึ่งตอบคำถามเดียว และชื่อกราฟบอกหน่วย
- ใช้ ChartPaints หนึ่งครั้งต่อหน้า กราฟทุกตัวมีมุมมองตาราง
- สีของชุดข้อมูลเรียงตามลำดับเดิมทุกกราฟ สีสถานะใช้กับสถานะเท่านั้น
ห้ามแสดง
- ตัวเลขที่ผู้ใช้ไม่มีสิทธิ์ดู ข้อมูลทุกตัวมาจาก core API ตามขอบเขตข้อมูลของผู้ใช้
- ข้อมูลส่วนบุคคลจริง เงินเดือนรายคน หรือเลขบัตรประชาชน
- กราฟสองแกน หรือตัวเลขที่ไม่มีใครใช้ตัดสินใจ
ในแอป
- หน้าเป็น server component ที่ดึงข้อมูลครั้งเดียว AppShell มาจาก layout
- console ใช้คอมโพเนนต์ชุดเดียวกัน AppThemeProvider ใน layout ทำให้เป็นสีม่วง
- ระหว่างโหลดใช้ Skeleton และ TableSkeleton ไม่ใช่ตัวหมุน
ตัวอย่างทั้งหน้า
แต่ละตัวอย่างเป็นหน้าเต็ม แสดงในกรอบจอคอมพิวเตอร์ เลือกโทรศัพท์หรือแท็บเล็ตที่แถบบนเพื่อดูบนจอนั้น ข้อมูลทั้งหมดเป็นข้อมูลสมมติ
ERP: ภาพรวมงบประมาณ
ตัวเลขสำคัญสี่ตัว งบประมาณตามหน่วยงาน การเบิกจ่ายเทียบเป้า สัดส่วนตามแหล่งเงิน และคำขอล่าสุด
// app/(erp)/dashboard/page.tsx: AppShell comes from the layout, so the page renders only its content.
// Every section is a Card. A chart in a Card with a header keeps its own title for screen readers only.
import { BarChart, Button, Card, ChartPaints, DashedContainer, DataTable, DonutChart, GaugeChart, Icon, IconButton, KpiTiles, PageHeader } from "@bsru/ui";
import { ArrowUpRight, CalendarClock, ChartColumn, ChartPie, ClipboardList, Plus, RefreshCw, Target, TrendingDown, Upload, Video } from "lucide-react";
import { getFormatter, getTranslations } from "next-intl/server";
import { getDashboard } from "@/server/core";
export default async function Dashboard() {
const t = await getTranslations("dashboard");
const format = await getFormatter();
// One call to the core API: every figure is already scoped to what this person may see.
const d = await getDashboard();
return (
<>
<ChartPaints />
<div className="flex flex-col gap-6 p-4 lg:p-6">
<PageHeader
kicker={t("kicker")}
title={t("title")}
description={t("intro")}
actions={
<>
<Button tone="primary" icon={Plus} label={t("newRequest")} href="/purchase-requests/new" />
<Button icon={Upload} label={t("import")} href="/import" />
</>
}
/>
<KpiTiles items={d.kpis} changeLabel={t("sinceLastMonth")} variant="cards" highlight={0} />
<div className="grid gap-6 lg:grid-cols-3">
<Card
className="lg:col-span-2"
title={t("budget.title")}
description={t("budget.intro", { year: d.year })}
icon={ChartColumn}
action={<IconButton icon={ArrowUpRight} label={t("budget.open")} href="/reports/budget" />}
>
<BarChart title={t("budget.title")} ariaLabel={t("budget.aria")} {...d.budgetByUnit} />
</Card>
<Card
title={t("spend.title")}
description={t("spend.period", { quarter: d.quarter, year: d.year })}
icon={Target}
footer={
<>
<Icon icon={TrendingDown} className="size-4" />
{t("spend.belowTarget", { points: d.spend.target - d.spend.value })}
</>
}
>
<GaugeChart title={t("spend.title")} label={t("spend.label")} targetLabel={t("spend.target")} restLabel={t("spend.rest")} {...d.spend} />
</Card>
</div>
<div className="grid gap-6 lg:grid-cols-3">
<Card
className="lg:col-span-2"
title={t("recent.title")}
description={t("recent.intro")}
icon={ClipboardList}
action={<Button tone="quiet" size="sm" label={t("recent.all")} href="/purchase-requests" />}
footer={
<>
<Icon icon={RefreshCw} className="size-4" />
{t("asOf", { time: format.dateTime(d.loadedAt, { dateStyle: "medium", timeStyle: "short" }) })}
</>
}
>
<DashedContainer>
<DataTable caption={t("recent.title")} columns={columns} rows={d.recent} rowKey="no" openHref={(r) => `/purchase-requests/${r.no}`} noun={t("noun")} />
</DashedContainer>
</Card>
<div className="flex flex-col gap-6">
<Card title={t("funds.title")} description={t("funds.total", { total: d.funds.total })} icon={ChartPie}>
<DonutChart title={t("funds.title")} ariaLabel={t("funds.aria")} {...d.funds} />
</Card>
{d.nextMeeting ? (
<Card
tone="feature"
title={d.nextMeeting.title}
description={d.nextMeeting.when}
icon={CalendarClock}
footer={<Button size="sm" icon={Video} label={t("meeting.join")} href={d.nextMeeting.url} />}
>
<p>{d.nextMeeting.room}</p>
</Card>
) : null}
</div>
</div>
</div>
</>
);
}| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| kpis | รายการ 4 รายการ[
{
label: "คำขอทั้งหมด",
value: "248",
unit: "รายการ",
change: 12.4,
trend: [180, 196, 205, 221, 236, 248],
},
{
label: "อนุมัติแล้ว",
value: "186",
unit: "รายการ",
change: 9.1,
trend: [130, 142, 151, 165, 174, 186],
},
{
label: "รออนุมัติ",
value: "41",
unit: "รายการ",
change: -6.8,
trend: [52, 49, 47, 45, 44, 41],
},
{
label: "เบิกจ่ายสะสม",
value: "62.0%",
change: 4.5,
trend: [22, 31, 40, 49, 57, 62],
},
] | array | — |
| budgetByUnit | ออบเจกต์ 7 ฟิลด์{
title: "งบประมาณตามหน่วยงานและแหล่งเงิน (ล้านบาท)",
ariaLabel: "งบประมาณตามหน่วยงานและแหล่งเงิน",
categories: ["หน่วยงาน ก", "หน่วยงาน ข", "หน่วยงาน ค", "หน่วยงาน ง"],
categoryHead: "หน่วยงาน",
series: ["งบแผ่นดิน", "เงินรายได้", "เงินกองทุน"],
values: [[24, 14, 6], [18, 16, 4], [12, 9, 8], [9, 6, 2]],
scales: {
group: { max: 30, ticks: [0, 10, 20, 30] },
stack: { max: 50, ticks: [0, 25, 50] },
},
} | object | — |
| spend | ออบเจกต์ 6 ฟิลด์{
title: "เบิกจ่ายเทียบเป้าไตรมาส",
label: "เบิกจ่าย",
value: 62,
target: 75,
targetLabel: "ถึงเป้า",
restLabel: "คงเหลือ",
} | object | — |
| funds | ออบเจกต์ 6 ฟิลด์{
title: "สัดส่วนตามแหล่งเงิน",
ariaLabel: "สัดส่วนงบประมาณตามแหล่งเงิน",
parts: [
{ label: "งบแผ่นดิน", value: 63 },
{ label: "เงินรายได้", value: 45 },
{ label: "เงินกองทุน", value: 20 },
],
unit: "ล้านบาท",
tipUnit: "ล้านบาท",
tableHead: ["แหล่งเงิน", "ล้านบาท"],
} | object | — |
| recent | รายการ 5 รายการ[
{
no: "PR-2570-0124",
item: "ครุภัณฑ์คอมพิวเตอร์โน้ตบุ๊ก 5 เครื่อง",
unit: "หน่วยงาน ก",
date: "2026-11-21",
amount: 150000,
status: "pending",
},
{
no: "PR-2570-0123",
item: "จ้างซ่อมเครื่องปรับอากาศ",
unit: "หน่วยงาน ข",
date: "2026-11-20",
amount: 42000,
status: "approved",
},
{
no: "PR-2570-0122",
item: "วัสดุสำนักงาน",
unit: "หน่วยงาน ค",
date: "2026-11-19",
amount: 18500,
status: "approved",
},
{
no: "PR-2570-0121",
item: "โต๊ะและเก้าอี้ห้องเรียน",
unit: "หน่วยงาน ก",
date: "2026-11-18",
amount: 86000,
status: "draft",
},
{
no: "PR-2570-0120",
item: "ค่าเช่าซอฟต์แวร์",
unit: "หน่วยงาน ง",
date: "2026-11-17",
amount: 64000,
status: "rejected",
},
] | array | — |
คอนโซล: ภาพรวมระบบ
หน้าเดียวกันในคอนโซล สีม่วงตาม AppThemeProvider: บัญชี การเข้าสู่ระบบรายวัน การยืนยันสองขั้น และบัญชีที่เพิ่มล่าสุด
// app/(console)/page.tsx: the console's layout wraps everything in AppThemeProvider app="console",
// so the same components draw in purple. Every section is a Card.
import { BarChart, Button, Card, ChartPaints, DashedContainer, DataTable, GaugeChart, Icon, IconButton, KpiTiles, PageHeader } from "@bsru/ui";
import { ArrowUpRight, Download, LogIn, MailCheck, Send, ShieldCheck, UserPlus, Users } from "lucide-react";
import { getTranslations } from "next-intl/server";
import { getOverview } from "@/server/core";
export default async function Overview() {
const t = await getTranslations("overview");
const o = await getOverview();
return (
<>
<ChartPaints />
<div className="flex flex-col gap-6 p-4 lg:p-6">
<PageHeader
kicker={t("kicker")}
title={t("title")}
description={t("intro")}
actions={
<>
<Button tone="primary" icon={UserPlus} label={t("addAccount")} href="/accounts/new" />
<Button icon={Download} label={t("export")} href="/reports/accounts" />
</>
}
/>
<KpiTiles items={o.kpis} changeLabel={t("sinceLastWeek")} variant="cards" highlight={0} />
<div className="grid gap-6 lg:grid-cols-3">
<Card
className="lg:col-span-2"
title={t("signIns.title")}
description={t("signIns.intro")}
icon={LogIn}
action={<IconButton icon={ArrowUpRight} label={t("signIns.open")} href="/audit/sign-ins" />}
>
<BarChart title={t("signIns.title")} ariaLabel={t("signIns.aria")} {...o.signInsByDay} />
</Card>
<Card
title={t("mfa.title")}
description={t("mfa.intro")}
icon={ShieldCheck}
footer={<Button tone="quiet" size="sm" icon={Send} label={t("mfa.remind", { count: o.mfa.missing })} href="/accounts/mfa-reminders" />}
>
<GaugeChart title={t("mfa.title")} label={t("mfa.label")} targetLabel={t("mfa.target")} {...o.mfa} />
</Card>
</div>
<Card
title={t("newest.title")}
description={t("newest.intro")}
icon={Users}
action={<Button tone="quiet" size="sm" label={t("newest.all")} href="/accounts" />}
footer={
<>
<Icon icon={MailCheck} className="size-4" />
{t("newest.note")}
</>
}
>
<DashedContainer>
<DataTable caption={t("newest.title")} columns={columns} rows={o.newest} rowKey="id" openHref={(r) => `/accounts/${r.id}`} noun={t("noun")} />
</DashedContainer>
</Card>
</div>
</>
);
}| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| kpis | รายการ 4 รายการ[
{
label: "บัญชีที่ใช้งาน",
value: "1,642",
unit: "บัญชี",
change: 3.2,
trend: [1540, 1566, 1590, 1611, 1630, 1642],
},
{
label: "เข้าสู่ระบบวันนี้",
value: "918",
unit: "ครั้ง",
change: 5.6,
trend: [780, 820, 845, 870, 902, 918],
},
{
label: "เข้าสู่ระบบไม่สำเร็จ",
value: "27",
unit: "ครั้ง",
change: -18.2,
trend: [44, 39, 36, 33, 30, 27],
},
{
label: "บัญชีที่ถูกล็อก",
value: "4",
unit: "บัญชี",
change: -50,
trend: [9, 8, 7, 6, 5, 4],
},
] | array | — |
| signInsByDay | ออบเจกต์ 7 ฟิลด์{
title: "การเข้าสู่ระบบรายวัน (ครั้ง)",
ariaLabel: "การเข้าสู่ระบบรายวัน แยกตามแอป",
categories: ["จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส.", "อา."],
categoryHead: "วัน",
series: ["ERP", "คอนโซล"],
values: [
[820, 42],
[870, 38],
[905, 51],
[880, 47],
[760, 35],
[140, 6],
[95, 4],
],
scales: {
group: { max: 1000, ticks: [0, 500, 1000] },
stack: { max: 1000, ticks: [0, 500, 1000] },
},
} | object | — |
| mfa | ออบเจกต์ 5 ฟิลด์{
title: "บัญชีที่เปิดใช้การยืนยันสองขั้น",
label: "เปิดใช้แล้ว",
value: 84,
target: 100,
targetLabel: "เป้า",
} | object | — |
| newest | รายการ 4 รายการ[
{
id: "U-10482",
name: "นายทดสอบ ตัวอย่าง",
role: "เจ้าหน้าที่การเงิน",
added: "2026-11-22",
status: "pending",
},
{
id: "U-10481",
name: "นางสาวสมมติ ใจดี",
role: "หัวหน้าหน่วยงาน",
added: "2026-11-21",
status: "approved",
},
{
id: "U-10480",
name: "นายจำลอง ทดลอง",
role: "เจ้าหน้าที่พัสดุ",
added: "2026-11-20",
status: "approved",
},
{
id: "U-10479",
name: "นางตัวอย่าง ข้อมูล",
role: "ผู้ตรวจสอบ",
added: "2026-11-19",
status: "rejected",
},
] | array | — |