Skip to content
العربية
App patterns

PageHeader

The top of a list or record page: the title with status badges, a meta line, a back link to the list, one primary action, secondary actions and a “⋯” menu. Below 768 px the primary action is full width and “More actions” opens the rest; secondary buttons stay mounted, so their dialogs keep working. Danger items go last. sticky keeps it under the AppShell header from 768 px. Menu items take a description, for example why an item is disabled. back also takes several links, for example “Client / Project”. Below 768 px, a dialog that opens from a “More actions” item gives the focus back to “More actions”.

import { PageHeader } from "@percentsa/ui";

Examples

Orders

128 orders
Code
export function PageHeaderListExample() {
  const t = useT();
  const done = (title: string) => () => toast({ title });
  return (
    <PageHeader
      className="w-full"
      headingLevel={2}
      title={t("Orders", "الطلبات")}
      meta={t("128 orders", "128 طلبًا")}
      primary={
        <Button onClick={done(t("New order", "طلب جديد"))}>
          <Plus aria-hidden />
          {t("New order", "طلب جديد")}
        </Button>
      }
      secondary={
        <Button variant="secondary" onClick={done(t("Export started", "بدأ التصدير"))}>
          <Download aria-hidden />
          {t("Export", "تصدير")}
        </Button>
      }
      menu={[
        { label: t("Import from a file", "استيراد من ملف"), icon: <Upload />, onSelect: done(t("Import", "استيراد")) },
        { label: t("Print the list", "طباعة القائمة"), icon: <Printer />, onSelect: done(t("Print", "طباعة")) },
      ]}
    />
  );
}

/** A project page: `back` takes a list of links, shown as a path. */
Invoices

INV-1042

OverdueSent
Nakheel Co.Due 30 September 202612,500.00
Code
export function PageHeaderDocumentExample() {
  const t = useT();
  const done = (title: string) => () => toast({ title });
  return (
    <PageHeader
      className="w-full"
      headingLevel={2}
      back={{ href: "#invoices", label: t("Invoices", "الفواتير") }}
      title="INV-1042"
      badges={
        <>
          <StatusBadge tone="warning">{t("Overdue", "متأخرة")}</StatusBadge>
          <StatusBadge tone="info">{t("Sent", "مرسلة")}</StatusBadge>
        </>
      }
      meta={
        <>
          <span>{t("Nakheel Co.", "شركة نخيل")}</span>
          <span>{t("Due 30 September 2026", "تستحق في 30 سبتمبر 2026")}</span>
          <Money amount={12500} decimals={2} />
        </>
      }
      primary={<Button onClick={done(t("Payment recorded", "سُجّلت الدفعة"))}>{t("Record payment", "تسجيل دفعة")}</Button>}
      secondary={
        <Dialog
          trigger={
            <Button variant="secondary">
              <Send aria-hidden />
              {t("Send", "إرسال")}
            </Button>
          }
          title={t("Send invoice", "إرسال الفاتورة")}
          description={t("Nakheel Co. gets a link to the invoice by email.", "تصل إلى شركة نخيل رسالة بريد فيها رابط الفاتورة.")}
          footer={
            <DialogClose asChild>
              <Button onClick={done(t("Invoice sent", "أُرسلت الفاتورة"))}>{t("Send", "إرسال")}</Button>
            </DialogClose>
          }
        />
      }
      menu={[
        { label: t("Delete", "حذف"), icon: <Trash2 />, danger: true, onSelect: done(t("Deleted", "حُذفت")) },
        { label: t("Duplicate", "تكرار"), icon: <Copy />, onSelect: done(t("Duplicated", "تم التكرار")) },
        {
          label: t("Send by WhatsApp", "إرسال عبر واتساب"),
          icon: <MessageCircle />,
          disabled: true,
          description: t("The customer has no mobile number.", "لا يوجد رقم جوال للعميل."),
        },
      ]}
    />
  );
}

/**
 * "Print the list" prints 30 orders on A4 landscape. The title and the column names repeat on every page, and nothing
 * else on the page prints. Over 500 rows an app turns the button off and says why.
 */

Main website

LiveWeb app
owner/main-website · main
Code
export function PageHeaderPathExample() {
  const t = useT();
  const done = (title: string) => () => toast({ title });
  return (
    <PageHeader
      className="w-full"
      headingLevel={2}
      back={[
        { href: "#al-noor", label: t("Al Noor", "النور") },
        { href: "#website", label: t("Website", "الموقع") },
      ]}
      title={t("Main website", "الموقع الرئيسي")}
      badges={
        <>
          <StatusDot status="live">{t("Live", "يعمل")}</StatusDot>
          <Badge>{t("Web app", "تطبيق ويب")}</Badge>
        </>
      }
      meta={<span dir="ltr">owner/main-website · main</span>}
      primary={<Button onClick={done(t("Redeploy started", "بدأت إعادة النشر"))}>{t("Redeploy", "إعادة النشر")}</Button>}
      secondary={
        <Button variant="secondary" onClick={done(t("Opening the site", "جارٍ فتح الموقع"))}>
          {t("Open site", "فتح الموقع")}
        </Button>
      }
      menu={[
        { label: t("New deployment…", "نشر جديد…"), onSelect: done(t("New deployment", "نشر جديد")) },
        { label: t("Delete app…", "حذف التطبيق…"), icon: <Trash2 />, danger: true, onSelect: done(t("Deleted", "حُذف")) },
      ]}
    />
  );
}

/** A record page: back to the list, status badges and a meta line. "Send" opens a dialog; Delete goes last; a disabled item says why. */