Sheet@knitui/sheet
Sheet
import { Sheet } from "@knitui/sheet";Sheet is the kit's bottom surface. It handles dialogs that hug their content, long lists with a pinned footer, forms that ride above the keyboard, and persistent panels over a map.
Snap points or content fit
Pass snapPoints as percentages of the screen, or snapPoints="fit" to hug the content up to maxHeight. An open panel re-settles on its own when the snap points or its content change. The content region ends at the resting snap, so Sheet.Footer stays on screen at every one.
Scrolling
Put anything that scrolls in Sheet.ScrollView or Sheet.FlatList, or pass renderSheetScrollComponent as another virtualized list's renderScrollComponent. These hand one finger between the list and the panel. A plain React Native ScrollView knows nothing about the sheet, and on Android the panel's drag stops it from scrolling.
Keyboard
moveOnKeyboardChange rides the whole panel above the soft keyboard, footer included, tracking it frame by frame while the scroller shrinks to fit. It defaults to the value of modal, so a persistent sheet stays where it is.
Persistent sheets
With modal={false} and withOverlay={false}, the sheet is a panel beside the page, and the page behind it keeps every touch. Controlled position and several snap points work as they do in a modal sheet.
Accessibility
title names the panel and adds a close button, which closeButtonProps can rename. With one snap point the handle is a drawn grabber, not a control. Escape and Android back close the topmost modal sheet first, and the spring honours reduced motion on every platform.
Playground
Loading playground…
<Sheet />Examples
Default
The default two-snap sheet ([80, 10]) with a handle.
Loading example…
Snap Points
Three snap points; dismissible by flinging past the lowest.
Loading example…
Custom Handle
A custom handle via the Sheet.Handle marker.
Loading example…
With Scroll View
Scrollable content inside the panel via Sheet.ScrollView, exercising the scroll↔drag handoff (native): at the top snap the list scrolls; drag it back to the top and keep pulling down and the sheet takes over (collapses to 40 %, then dismisses). From the 40 % snap a drag moves the sheet, not the list.
Loading example…
With Header And Footer
A fixed header + footer via the Sheet.Header / Sheet.Footer markers. Both stay pinned (below the handle / above the bottom edge) while the Sheet.ScrollView between them scrolls independently — the scroll region is squeezed between the two fixed bars.
Loading example…
Sizes
Top-corner rounding scale.
Loading example…
Controlled Only
Non-dismissible (no overlay press / snap-to-bottom); close via a button.
Loading example…
Fit Content
snapPoints="fit" hugs the content, and follows it when it changes height.
Loading example…
Fit With Max Height
A long list stops at maxHeight and scrolls above the pinned footer.
Loading example…
Pinned Footer
The footer sits on the panel's visible bottom edge at every snap.
Loading example…
Changing Snap Points
New snap points move an open panel without a snapTo call.
Loading example…
With Keyboard
The whole panel rides above the keyboard (native), and the list shrinks to fit.
Loading example…
Persistent
A persistent sheet leaves the page behind it free to take touches.
Loading example…
Virtualized List
Sheet.FlatList gives a virtualized list the same scroll handoff.
Loading example…
Centred On Wide Screens
maxWidth centres the panel on tablets and wide windows.
Loading example…
Stacked
Two modal sheets: Escape and Android back close the topmost first.
Loading example…
Styles
Per-slot styles overrides (root / overlay / handle).
Loading example…
Props
| Prop | Type | Default | Description |
|---|---|---|---|
animationConfig | SpringConfig | undefined | — | Per-instance spring override (passed to reanimated `withSpring`). |
aria-label | string | undefined | — | Accessible name of the panel. On web it is set on the element that carries the role (the dialog, or the region of a non-modal sheet); on native it becomes the panel's `accessibilityLabel`. Takes precedence over `title`. |
aria-labelledby | string | undefined | — | Id of the element that names the panel (typically its visible title), set on the element that carries the role. Web only; takes precedence over `aria-label` for assistive tech. |
bottomInset | number | undefined | — | Space kept clear under the content or footer. Defaults to the bottom safe area on native (from `react-native-safe-area-context`) and to `env(safe-area-inset-bottom)` on web. Pass `0` to opt out. |
children | ReactNode | — | `Sheet.Overlay` / `Sheet.Handle` / `Sheet.Header` / `Sheet.Footer` / `Sheet.Frame` markers, or plain content (which folds into the panel). |
closeButtonProps | { "aria-label"?: string; } | undefined | { "aria-label": "Close" } | Close button props. Set `aria-label` to name it. |
closeOnBackPress | boolean | undefined | true | Android hardware back closes a modal sheet, topmost first. |
closeOnBrowserBack | boolean | undefined | false | Web: the browser's Back button (or back gesture) closes the open sheet, as Android's hardware back does. The sheet adds one history entry while open, without changing the URL, and removes it when it closes any other way. Off by default because it touches the page's history. No effect on native. |
closeOnEscape | boolean | undefined | true | Escape closes the sheet (web), topmost modal sheet first. |
defaultOpened | boolean | undefined | false | Uncontrolled initial open state on mount. |
defaultPosition | number | undefined | 0 (most open) | Uncontrolled initial snap-point index. |
disableDrag | boolean | undefined | false | Disable all drag handling. |
disableRemoveScroll | boolean | undefined | false | Opt out of locking body scroll while a modal sheet is open (web). |
dismissOnOverlayPress | boolean | undefined | true | Tapping the scrim closes the sheet. A tap within the first moments after opening is ignored, so the second tap of a double tap on the opener can't close it again. |
dismissOnSnapToBottom | boolean | undefined | false | Dragging past the lowest snap closes the sheet. |
maxHeight | number | `${number}%` | undefined | — | The tallest a `snapPoints="fit"` panel may grow: px, or a `"NN%"` share of the screen. Defaults to the screen below the top safe area. |
maxWidth | number | undefined | — | Cap the panel's width and centre it, for tablets and wide windows. |
modal | boolean | undefined | true | A modal sheet is teleported to the app root and exposed as a dialog (`role="dialog"` + `aria-modal="true"` on web, `accessibilityViewIsModal` on native). A non-modal sheet renders inline as a persistent panel: not a dialog, but a `role="region"` landmark when it has an accessible name (`aria-label` / `aria-labelledby`), and no role without one. |
moveOnKeyboardChange | boolean | undefined | the value of `modal` | Ride the whole panel, footer included, above the soft keyboard, tracking it while the scrollable content shrinks to fit. Native tracks it frame by frame; mobile web follows the browser's visual viewport. |
onClose | (() => void) | undefined | — | Called whenever the sheet requests to close — overlay press, drag-to-dismiss, Escape, snap-to-bottom, or the imperative `close()`. Fires after the close animation in uncontrolled mode; immediately in controlled mode. |
onPositionChange | ((position: number) => void) | undefined | — | Called when the resting snap-point index changes. |
opened | boolean | undefined | — | Controlled open state. |
overlayProps | OverlayProps | undefined | — | Props forwarded to the underlying `Overlay` scrim. |
padded | boolean | undefined | false | Pad the content region with the kit's standard gutter. |
position | number | undefined | — | Controlled snap-point index (into `snapPoints`). |
returnFocus | boolean | undefined | true | Return focus to the previously-focused element on close (web). |
size system | SheetSize | undefined | "lg" | Top-corner rounding scale. |
snapPoints | number[] | "fit" | undefined | [80, 10] | Snap points as % of the screen the sheet occupies, ordered most-visible → least-visible, or `"fit"` for one snap that hugs the panel's content. A fit panel measures the handle, header, content and footer, follows content that changes height while open, and stops at {@link SheetProps.maxHeight}, where a `Sheet.ScrollView` starts to scroll. |
style | void | StylePiece | Falsy | (Readonly<Omit<Readonly<Omit<Readonly<{ display?: "none" | "flex" | "contents" | undefined; width?: DimensionValue | undefined; height?: DimensionValue | undefined; bottom?: DimensionValue | undefined; end?: Dime… | — | Inline style on the panel surface. |
styles system | SlotStyles<SheetStyles> | undefined | — | Per-slot style overrides. See {@link SheetStyles}. |
testID | string | undefined | — | — |
title | ReactNode | — | Title shown in the header. Also names the panel for assistive tech. |
trapFocus | boolean | undefined | true | Trap keyboard focus within the panel while open (web). |
withCloseButton | boolean | undefined | `true` when `title` is set | Show a close button in the header. |
withHandle | boolean | undefined | true | Show the default drag handle when no `Sheet.Handle` is provided. |
withOverlay | boolean | undefined | true | Render the scrim behind the panel. |
zIndex | number | undefined | 200 | Root stack order. |
Style slots
Every part of Sheet can be styled through the styles prop. Explicit props on the component always win over slot styles.
| Slot | Targets |
|---|---|
body | The content region between header and footer. |
closeButton | The close button. |
footer | The fixed footer region (Sheet.Footer). |
handle | The drag handle bar (Sheet.Handle). |
header | The fixed header region (Sheet.Header). |
overlay | The scrim (Sheet.Overlay). |
root | The panel surface (Sheet.Frame). |
title | The title. |
Accessibility & DOM props (2)
| Prop | Type |
|---|---|
key | Key | null | undefined |
ref | Ref<SheetRef> | undefined |