@biem/ui

Sheet

A panel that slides in from an edge of the screen, in which users read details or complete a task.

A sheet slides a panel in from an edge of the screen, where users read details or complete a task without leaving the page. By default, it enters from the right edge and takes the full height of the screen. While it is open, focus stays in the sheet and the page behind it doesn't scroll. Users close it with the close button, the Escape key or a press outside the sheet.

Usage

sheet-default.tsx
import { Button } from "@biem/ui/components/ui/button";
import {
	Sheet,
	SheetContent,
	SheetDescription,
	SheetHeader,
	SheetTitle,
	SheetTrigger,
} from "@biem/ui/components/ui/sheet";

export function SheetDefault() {
	return (
		<Sheet>
			<SheetTrigger render={<Button variant="outline"/>}>Delivery details</SheetTrigger>
			<SheetContent>
				<SheetHeader>
					<SheetTitle>Delivery details</SheetTitle>
					<SheetDescription>
						The warehouse delivers 12 cases on Tuesday between 6:00 and 8:00. The store checks them in at the back entrance.
					</SheetDescription>
				</SheetHeader>
			</SheetContent>
		</Sheet>
	);
}

Examples

Top Side

Content that relates to the entire page, such as the filters of a product list, can open from above. With side set to "top", the sheet slides down across the full width of the screen and takes only the height its content needs.

Bottom Side

On a phone, the lower edge of the screen lies within reach of the thumb, which suits short tasks such as choosing a store. Set to "bottom", side lets the sheet rise from that edge, again across the full width and only as tall as its content.

Left Side

Navigation and filters often sit at the left edge of a page, and a sheet that holds them appears where users already look for them. Through side set to "left", the sheet enters from that edge and takes the full height of the screen, as it does on the right.

A sheet in which users complete a task ends with the actions that conclude it. Collected in SheetFooter, these actions follow everything users need to read before they decide. An action that abandons the task works through SheetClose, so it closes the sheet without further code.

Without Close Button

When the footer already offers a way to leave the task, a second close button only adds another choice. With showCloseButton set to false, the sheet leaves that button out, and users still close it through an action in the sheet, the Escape key or a press outside.

Controlled

The application sometimes decides when the sheet closes, for example only after a delivery has been booked into stock. Through open and onOpenChange it holds the open state, so an action inside the sheet closes it once its work is done, and any other part of the interface can open it.

Disabled Trigger

Details are not always available when users look for them, for example while a delivery still waits for its time slot. Marked as disabled, the trigger stays visible but no longer opens the sheet, so users know the details exist before they can read them.

Disabled Close

Closing a sheet can depend on the state of the task, for example when an action should end it only once every count has been entered. Once it carries disabled, SheetClose no longer closes the sheet, and users close it in the other ways instead.

API Reference

Sheet

Propopen
Typeboolean
Default–
DescriptionSets whether the sheet is open and makes it controlled. Update it in onOpenChange.
PropdefaultOpen
Typeboolean
Defaultfalse
DescriptionOpens the sheet at first render. The sheet then tracks its open state itself.
ProponOpenChange
Type(open: boolean, eventDetails: DialogRootChangeEventDetails) => void
Default–
DescriptionRuns when users open or close the sheet. It receives the open state that follows.
ProponOpenChangeComplete
Type(open: boolean) => void
Default–
DescriptionRuns after the sheet has opened or closed and its animations have finished.
Propmodal
Typeboolean | "trap-focus"
Defaulttrue
DescriptionSets how the sheet limits the rest of the page while it is open. With true, focus stays in the sheet and the page doesn't scroll. With "trap-focus", focus stays in the sheet, but the page scrolls. With false, focus can move to the rest of the page, and the page scrolls. The overlay covers the page in each case.
PropdisablePointerDismissal
Typeboolean
Defaultfalse
DescriptionKeeps the sheet open when users press outside of it. A sheet with modal set to false then also stays open when focus moves outside of it.
ProptriggerId
Typestring | null
Default–
DescriptionSets the ID of the trigger that a controlled sheet is associated with. A sheet without open doesn't need it.
PropdefaultTriggerId
Typestring | null
Default–
DescriptionSets the ID of the trigger that the sheet is associated with when defaultOpen opens it at first render.
Prophandle
TypeDialogHandle<Payload>
Default–
DescriptionConnects the sheet with triggers that are rendered outside of it. Create the handle with Dialog.createHandle() from @base-ui/react/dialog.
PropactionsRef
TypeRefObject<DialogRootActions | null>
Default–
DescriptionReceives the functions close and unmount. close closes the sheet from code, and unmount removes it from the DOM after a closing animation that the code controls itself.
Propchildren
TypeReactNode | ((arg: { payload: Payload | undefined }) => ReactNode)
Default–
DescriptionHolds the parts of the sheet. A function receives the payload of the trigger that opened the sheet.

SheetTrigger

Prophandle
TypeDialogHandle<Payload>
Default–
DescriptionConnects the trigger with a sheet that it is rendered outside of. Pass the same handle to Sheet.
Proppayload
TypePayload
Default–
DescriptionPasses a value to the sheet when this trigger opens it. A function as children of Sheet receives it.
Propid
Typestring
Default–
DescriptionSets the ID of the trigger element. triggerId and defaultTriggerId of Sheet refer to it.
Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the trigger with another component.
PropnativeButton
Typeboolean
Defaulttrue
DescriptionDeclares whether the rendered element is a native button. Set it to false when render returns a different element.
Propdisabled
Typeboolean
Defaultfalse
DescriptionPrevents users from opening the sheet with this trigger.

SheetContent

Propside
Type"top" | "right" | "bottom" | "left"
Default"right"
DescriptionSets the edge of the screen that the sheet slides in from. On the left and the right edge, the sheet takes the full height of the screen and three quarters of its width, at most 24rem from the sm breakpoint. On the top and the bottom edge, it takes the full width, and its height follows its content.
PropshowCloseButton
Typeboolean
Defaulttrue
DescriptionShows the close button in the top right corner of the sheet.
PropinitialFocus
Typeboolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | HTMLElement | null | void)
Default–
DescriptionDetermines the element that receives focus when the sheet opens. Without it, focus moves to the first focusable element in the sheet, or to the sheet itself when users open it by touch.
PropfinalFocus
Typeboolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | HTMLElement | null | void)
Default–
DescriptionDetermines the element that receives focus when the sheet closes. Without it, focus returns to the trigger or to the element that had focus before.
Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the content with another component.

SheetHeader

SheetHeader groups the title and the description. It renders a div and has no props of its own.

SheetTitle

Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the title with another component.

SheetDescription

Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the description with another component.

SheetFooter

SheetFooter stacks the actions at the end of the sheet. It renders a div and has no props of its own.

SheetClose

Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the close button with another component.
PropnativeButton
Typeboolean
Defaulttrue
DescriptionDeclares whether the rendered element is a native button. Set it to false when render returns a different element.
Propdisabled
Typeboolean
Defaultfalse
DescriptionPrevents users from closing the sheet with this button.