Skip to content
العربية
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

Invoices
InvoiceField 1Field 2Field 3Field 4Field 5Field 6Field 7
INV-1040Value 1.1Value 1.2Value 1.3Value 1.4Value 1.5Value 1.6Value 1.7
INV-1041Value 2.1Value 2.2Value 2.3Value 2.4Value 2.5Value 2.6Value 2.7
INV-1042Value 3.1Value 3.2Value 3.3Value 3.4Value 3.5Value 3.6Value 3.7
INV-1043Value 4.1Value 4.2Value 4.3Value 4.4Value 4.5Value 4.6Value 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>
  );
}