Skip to content
العربية
Data display

Timeline

Events or steps in order, with the line on the start side. A step can show its state, its duration and a detail. A failed step opens to show its detail.

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

Examples

  1. 09:12
    Order placed
    Done
  2. 09:14
    Paid with mada
    Done
  3. 11:40
    Packed
    Riyadh warehouse
  4. Tomorrow
    Out for delivery
  5. Tomorrow
    Delivered
Code
export function TimelineExample() {
  const t = useT();
  return (
    <Timeline
      className="w-full max-w-sm"
      items={[
        { id: "placed", time: "09:12", title: t("Order placed", "تم الطلب"), status: "done" },
        { id: "paid", time: "09:14", title: t("Paid with mada", "تم الدفع عبر مدى"), status: "done" },
        { id: "packed", time: "11:40", title: t("Packed", "تم التغليف"), description: t("Riyadh warehouse", "مستودع الرياض"), status: "current" },
        { id: "out", time: t("Tomorrow", "غدًا"), title: t("Out for delivery", "خرج للتوصيل"), status: "next" },
        { id: "delivered", time: t("Tomorrow", "غدًا"), title: t("Delivered", "تم التسليم"), status: "next" },
      ]}
    />
  );
}
  1. 4 s
    Done
  2. 1 min 12 s
    Failed
    $ bun run build
    error: Cannot find module './shop'
    exit code 1
  3. Skipped
  4. Waiting

Selected: Build

Code
export function TimelineStepsExample() {
  const t = useT();
  const [selected, setSelected] = useState("build");
  const names: Record<string, string> = { clone: t("Clone", "استنساخ"), build: t("Build", "بناء"), start: t("Start", "تشغيل"), check: t("Check", "فحص") };
  return (
    <div className="grid w-full max-w-sm gap-4">
    <Timeline
      onSelect={setSelected}
      items={[
        { id: "clone", title: t("Clone", "استنساخ"), status: "done", duration: t("4 s", "4 ث") },
        {
          id: "build",
          title: t("Build", "بناء"),
          status: "failed",
          duration: t("1 min 12 s", "1 د 12 ث"),
          detail: (
            <pre dir="ltr" className="font-mono text-xs whitespace-pre-wrap">
              {"$ bun run build\nerror: Cannot find module './shop'\nexit code 1"}
            </pre>
          ),
        },
        { id: "start", title: t("Start", "تشغيل"), status: "skipped" },
        { id: "check", title: t("Check", "فحص"), status: "waiting" },
      ]}
    />
    <p className="text-sm text-fg-2">
      {t("Selected: ", "المحدد: ")}
      {names[selected]}
    </p>
    </div>
  );
}