This browser is not supported. The glass needs a Chromium browser or Electron. Why

Sheet

A panel that slides up from the bottom and rests at detents. Below large it is glass; at large it is opaque and fills the width.

import { FullScreenCover, Sheet, useSheetMetrics } from "@adamexu/glass";

Detents

A finger drives the sheet one to one, with a rubber band past the ends. A release picks the detent its speed projects to, or dismisses it past halfway down. A tap on the grabber goes to the next detent, and a mouse wheel scrolls the content, or pulls the sheet like a finger when there is nothing to scroll that way. The glass to opaque change happens near the middle under a finger, and on a spring.

As in research's demo app, the content is a NavigationStack with metrics={useSheetMetrics()}, so its bar fits the sheet; its page's scroller is what scrolls inside, and a drag in the content resizes the sheet up to the largest detent before it scrolls. The demos sit in a PresentationRoot over their phone frame (see Alert).

closed
function SheetPage({ title, rows, close }) {
  const metrics = useSheetMetrics();
  return (
    <NavigationStack
      metrics={metrics}
      root={
        <NavigationPage
          title={title}
          titleDisplayMode="inline"
          toolbar={
            <>
              <ToolbarItem placement="topBarLeading" title="Close" icon={CloseGlyph} onAction={close} />
              <ToolbarItem placement="topBarTrailing" title="Done" icon={ConfirmGlyph} prominent onAction={close} />
            </>
          }
        >
          <List>
            <Section>
              {Array.from({ length: rows }, (_, i) => <Text key={i}>Item {i + 1}</Text>)}
            </Section>
          </List>
        </NavigationPage>
      }
    />
  );
}

const [open, setOpen] = useState(false);

<Button buttonStyle="glass" onClick={() => setOpen(true)}>Show Sheet</Button>
<Sheet
  isPresented={open}
  onDismiss={() => setOpen(false)}
  detents={["medium", "large"]}
  onSelectedDetentChange={setDetent}
  aria-label="Sheet"
>
  <SheetPage title="Sheet" rows={20} close={() => setOpen(false)} />
</Sheet>

A sheet presented from inside a sheet's content stacks over it.

Not dismissible

With interactiveDismissDisabled no drag, outside tap or Escape closes it: a drag down rubber-bands, and only your own button sets isPresented back to false. dragIndicator="visible" shows the grabber with one detent.

<Button buttonStyle="glass" onClick={() => setOpen(true)}>Edit Profile</Button>
<Sheet
  isPresented={open}
  onDismiss={() => setOpen(false)}
  detents={["medium"]}
  dragIndicator="visible"
  interactiveDismissDisabled
  aria-label="Edit Profile"
>
  <SheetPage title="Edit Profile" rows={4} close={() => setOpen(false)} />
</Sheet>

FullScreenCover

The whole window, opaque, sliding up on the sheet's spring. It has no drag; Escape dismisses it.

<Button buttonStyle="glass" onClick={() => setOpen(true)}>Show Cover</Button>
<FullScreenCover isPresented={open} onDismiss={() => setOpen(false)} aria-label="Cover">
  <SheetPage title="Cover" rows={30} close={() => setOpen(false)} />
</FullScreenCover>

Props

Sheet

PropTypeDefaultDescription
isPresentedboolean-Required. Shown while true.
onDismiss() => void-Runs when a drag, an outside tap or Escape dismisses it: set isPresented back to false.
detents("medium" | "large" | { fraction: number } | { height: number })[]["large"]The heights it rests at.
selectedDetentnumber0Index in detents: the one it opens at, and moves to when it changes.
onSelectedDetentChange(index: number) => void-Runs when it settles at another detent.
dragIndicator"automatic" | "visible" | "hidden""automatic"The grabber. automatic shows it with more than one detent.
cornerRadiusnumber-Overrides the corner radius.
backgroundstring-One colour instead of the glass and the opaque look.
interactiveDismissDisabledbooleanfalseNo dismissing drag, outside tap or Escape (a rubber band past the bottom).
contentInteraction"automatic" | "resizes" | "scrolls""automatic"automatic and resizes: a drag in the content resizes the sheet up to the largest detent, then scrolls. scrolls: it scrolls.
sizing"automatic" | "form" | "page" | { fittedHeight: number }"automatic"On an iPad-sized window (1032 px both ways) with no detents: a centered form, a page, or a form of that height.
aria-labelstring"Sheet"On the sheet's dialog.
childrenReactNode-The content.
glass{ frostSize?: number; tableSize?: number; tintAmount?: number }-Fitting only: which measured sizes draw the glass.

FullScreenCover

PropTypeDefaultDescription
isPresentedboolean-Required. Shown while true.
onDismiss() => void-Runs on Escape: set isPresented back to false.
backgroundstringwhite, black in darkThe cover's colour.
aria-labelstring"Cover"On the cover's dialog.
childrenReactNode-The content.

useSheetMetrics

PropTypeDefaultDescription
useSheetMetrics()Metrics-The bar metrics of the sheet it is called in: pass them to a NavigationStack inside as metrics.

Behaviour

On a phone a sheet below large floats scaled, in from the sides. Its glass presses and leans sideways under a finger. Both portal to the root of their PresentationRoot, or document.body, take focus when they open (Tab stays inside) and give it back when they close. Their layout follows the idiom and the window's size. The glass targets Chromium.

SwiftUI

SwiftUI@adamexu/glass
.sheet(isPresented:) { }<Sheet isPresented onDismiss>
.presentationDetents([.medium, .large], selection:)<Sheet detents={["medium", "large"]} selectedDetent onSelectedDetentChange>
.presentationDetents([.fraction(0.3), .height(300)])detents={[{ fraction: 0.3 }, { height: 300 }]}
.presentationDragIndicator(.visible)dragIndicator="visible"
.presentationCornerRadius(r) / .presentationBackground(c)cornerRadius={r} / background={c}
.interactiveDismissDisabled()interactiveDismissDisabled
.presentationContentInteraction(.scrolls)contentInteraction="scrolls"
.presentationSizing(.form / .page / .fitted)sizing="form" / "page" / { fittedHeight }
.fullScreenCover(isPresented:) { }<FullScreenCover isPresented onDismiss>