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

FormBar

The action bar at the end of a form page or a long sheet form: a short live summary at the start (a total, a count; screen readers read changes politely) and the buttons at the end, secondary first and the submit last. From 640 px it is one row; below that the summary has its own line and the buttons share the row equally. It sticks to the bottom of the scroll area; sticky={false} turns that off. Put the value in <b> for medium weight. In a Sheet, give it className="-mx-6 -mb-6 px-6" to reach the sheet's edges.

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

Examples

Stocktake

Optional
Products that change: 3
Code
export function FormBarExample() {
  const t = useT();
  const [count, setCount] = useState(3);
  return (
    <form noValidate onSubmit={noSubmit} className="h-80 w-full max-w-3xl overflow-auto rounded-card border border-line bg-bg">
      <div className="grid gap-4 p-4">
        <Card title={t("Stocktake", "الجرد")}>
          <Stack gap={4}>
            <Field label={t("Warehouse", "المستودع")}>
              <Input defaultValue={t("Main warehouse", "المستودع الرئيسي")} />
            </Field>
            <Field label={t("Products that changed", "المنتجات التي تغيّرت")}>
              <Input inputMode="numeric" dir="ltr" value={count} onChange={(e) => setCount(Number(e.target.value.replace(/\D/g, "")) || 0)} />
            </Field>
            <Field label={t("Note", "ملاحظة")} optional>
              <Textarea rows={5} />
            </Field>
          </Stack>
        </Card>
      </div>
      <FormBar
        summary={
          <>
            {t("Products that change: ", "منتجات ستتغير: ")}
            <b>{count}</b>
          </>
        }
      >
        <Button variant="secondary">{t("Cancel", "إلغاء")}</Button>
        <Button type="submit">{t("Save stocktake", "حفظ الجرد")}</Button>
      </FormBar>
    </form>
  );
}

/** A bar with a money summary and no stickiness, as at the end of a short sheet form. */
Total: 1,150.00
Code
export function FormBarTotalExample() {
  const t = useT();
  return (
    <FormBar
      sticky={false}
      className="w-full max-w-3xl rounded-card border"
      summary={
        <>
          {t("Total: ", "الإجمالي: ")}
          <b>
            <Money amount={1150} decimals={2} />
          </b>
        </>
      }
    >
      <Button variant="secondary">{t("Cancel", "إلغاء")}</Button>
      <Button type="submit">{t("Create quote", "إنشاء العرض")}</Button>
    </FormBar>
  );
}

/** A device lock: 1234 is the code in this example; other codes show the error. */