Navigation
Tabs
Switch between views of the same subject. Arrow keys follow the reading direction. The underline slides to the chosen tab (no slide with reduced motion). Inside a grid the tabs and the panels can shrink, so a wide table scrolls in its own box.
import { Tabs } from "@percentsa/ui";Examples
| Invoice | Field 1 | Field 2 | Field 3 | Field 4 | Field 5 | Field 6 | Field 7 |
|---|---|---|---|---|---|---|---|
| INV-1040 | Value 1.1 | Value 1.2 | Value 1.3 | Value 1.4 | Value 1.5 | Value 1.6 | Value 1.7 |
| INV-1041 | Value 2.1 | Value 2.2 | Value 2.3 | Value 2.4 | Value 2.5 | Value 2.6 | Value 2.7 |
| INV-1042 | Value 3.1 | Value 3.2 | Value 3.3 | Value 3.4 | Value 3.5 | Value 3.6 | Value 3.7 |
| INV-1043 | Value 4.1 | Value 4.2 | Value 4.3 | Value 4.4 | Value 4.5 | Value 4.6 | Value 4.7 |
Code
export function TabsExample() {
const t = useT();
const columns: DataTableColumn<TabRow>[] = [
{ key: "id", header: t("Invoice", "الفاتورة"), cell: (r) => r.id },
...Array.from({ length: 7 }, (_, k): DataTableColumn<TabRow> => ({ key: `c${k}`, header: `${t("Field", "الحقل")} ${k + 1}`, cell: (r) => r.c[k], width: "9rem" })),
];
return (
<div className="grid w-full max-w-lg grid-cols-1 gap-3">
<Tabs
defaultValue="overview"
items={[
{ value: "overview", label: t("Overview", "نظرة عامة"), content: <DataTable columns={columns} rows={TAB_ROWS} getRowId={(r) => r.id} caption={t("Invoices", "الفواتير")} hideCaption /> },
{ value: "scope", label: t("Scope", "النطاق"), content: <Text tone="muted">{t("What we build.", "ما نبنيه.")}</Text> },
{ value: "timeline", label: t("Timeline", "الجدول الزمني"), content: <Text tone="muted">{t("When it ships.", "متى يُطلق.")}</Text> },
]}
/>
</div>
);
}