Skip to content
العربية
Overlays

Sheet

A panel from a side or the bottom. end is right in English and left in Arabic. On touch, drag it toward its side to close it: past 30 % of its size or with a flick, else it springs back. A bottom sheet drags from its handle and header, or from the content when that is scrolled to the top. A mouse never drags. Sliders, text fields, horizontal scrollers, menus opened from the sheet and parts marked data-sheet-no-drag keep their own drag. size="lg" makes a side sheet 56rem wide (the default is 28rem), for a document made from another document; a bottom sheet ignores it. returnFocusTo names the element that gets the focus when the panel closes, for example a section heading after a link in the panel moved the person there. Without it, the focus goes back to the element that had the focus when the panel opened. It works only without trigger. The element must take the focus (a heading needs tabIndex={-1}).

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

Examples

Code
export function SheetExample() {
  const t = useT();
  return (
    <Inline gap={3}>
      <Sheet trigger={<Button variant="secondary">{t("Filters", "التصفية")}</Button>} title={t("Filters", "التصفية")}>
        <Field label={t("Budget", "الميزانية")}>
          <Slider min={10} max={500} step={10} defaultValue={[120, 360]} />
        </Field>
      </Sheet>
      <Sheet side="bottom" trigger={<Button variant="secondary">{t("From the bottom", "من الأسفل")}</Button>} title={t("Details", "التفاصيل")}>
        <Text tone="muted">{t("Good for phones. On touch, drag the handle down to close.", "مناسب للجوال. باللمس اسحب المقبض إلى الأسفل للإغلاق.")}</Text>
      </Sheet>
    </Inline>
  );
}
Code
export function SheetLargeExample() {
  const t = useT();
  return (
    <Sheet size="lg" trigger={<Button variant="secondary">{t("Convert to order", "تحويل إلى طلب")}</Button>} title={t("Convert to order", "تحويل إلى طلب")}>
      <Text tone="muted">{t("56rem wide on a wide screen, the full width on a phone.", "بعرض 56rem على الشاشة العريضة، وبالعرض الكامل على الجوال.")}</Text>
    </Sheet>
  );
}