Todae

Todae

useSheetPresentation

useSheetPresentation chooses a sheet when the pointer is coarse or the viewport is narrower than 640px, and a popover otherwise. Those are defaults: coarseQuery and narrowWidth change them. Unless forced is 'popover' or 'sheet', server render and the first paint are popover. isSheet mirrors presentation === "sheet"; it is not isTouch. useCombobox uses it for presentation: 'auto'. resolveSheetPresentation({ coarse, narrow }) is its rule without the media queries: 'sheet' when either is true.

On this page
import { Text, useSheetPresentation } from '@tounsoo/todae';

export default function PresentationBadge() {
  const sheet = useSheetPresentation();
  return (
    <Text.Root>
      {sheet.presentation} · isSheet={String(sheet.isSheet)}
    </Text.Root>
  );
}

popover · isSheet=false

When to use

When: Choose popover or sheet at runtime: coarse pointer or width under 640px (by default) → sheet. SSR and first paint are popover. forced overrides.

When not: Always a centered modal → Dialog. Always a sheet → BottomSheet alone. Desktop-only anchored overlay → usePopover alone.

Props

useSheetPresentation props
NameTypeDescription
narrowWidthnumber

Viewport width that starts the narrow media query. Media is max-width: n - 1.

Default: 640

coarseQuerystring

matchMedia query treated as coarse pointer.

Default: '(pointer: coarse)'

forced"popover" | "sheet" | "auto"

Skip media when popover or sheet. auto uses coarse OR narrow.

Default: "auto"

resolveSheetPresentation props
NameTypeDescription
coarse Requiredboolean

Whether the pointer is coarse.

narrow Requiredboolean

Whether the viewport is narrow.