Skip to content

React Slide-Over Panel (Side Drawer)

A glass React slide-over panel, or side drawer, that slides in to edit a record or show its details, with an edit form that guards unsaved changes.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/side-drawer.json

Maya Chen

Designer

Edit form

Save with an empty name to see inline errors, the announced summary and focus jumping to the first problem. Edit something, then press Escape, the scrim or × (or swipe it away on a phone): you are asked before your changes are thrown away. ⌘↵ / Ctrl+Enter saves.

Ada Lovelace

ada@example.com

Admin

Design engineer. Glass, motion and accessible UI.

Files to copy

20 folders · 19 files · 5 packages
From theme/src/
  • components/description-list/
  • components/side-drawer/
  • components/alert-dialog/
  • components/badge/
  • components/button/
  • components/drawer/
  • components/empty-state/
  • components/input/
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/spinner/
  • components/status-icons/
  • components/tabs/
  • components/toast/
  • components/tooltip/
  • hooks/{use-controllable.ts, use-direction.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{cn.ts, field-size.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, modal-tab-trap.ts, popup-a11y.ts, popup-motion.ts, state-light.tsx, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/side-drawer.jsonRegistry item: side-drawer. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/alert/
  • components/avatar/
  • components/checkbox/
  • components/data-table/
  • components/pagination/
  • components/progress/
  • components/select/
  • components/switch/
  • components/textarea/
  • components/timeline/
  • hooks/use-virtual-window.ts
  • motion/reorder.tsx
  • lib/{csv.ts, field-control-shell.tsx, group-segments.ts, initials.ts, motion-props.ts, no-script-reveal.tsx, page-size.ts}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/avatar.json https://lokendra-builds.github.io/sheenui/r/data-table.json https://lokendra-builds.github.io/sheenui/r/select.json https://lokendra-builds.github.io/sheenui/r/switch.json https://lokendra-builds.github.io/sheenui/r/textarea.json https://lokendra-builds.github.io/sheenui/r/timeline.json
Packages
pnpm add @base-ui/react @tanstack/react-table clsx motion tailwind-merge

Detail view, edit in place

Header with avatar, status and a copyable id; tabs for Overview, Activity and Notes. Edit swaps the details for a form in the same drawer, and Save or Cancel slides you back. Saving, Duplicate and Archive keep the drawer open, so they confirm in place (a check next to the title, announced) instead of a toast over the header. A half-written note also asks before the drawer closes.

Order #1042

Paid

Grace Hopper · $139.00

From a data table

Open a customer from their name (or the row menu: View details / Edit). Walk the rows in the table’s current sort and search order with the arrows in the footer or J / K; a half-written note stays with its customer, and closing asks before dropping it. Each record loads for a moment (skeleton); the 7th fails once to show the error state. Closing returns focus to the row you ended on.

Sizes and resizing

Four widths, and an optional handle on the free edge that remembers where you left it.

Inspector (non-modal)

modal={false}: no scrim and no focus trap, so the list stays usable while the panel is open. Clicking another file updates it; clicking the shown file again clears the selection (the empty state). Escape closes it while focus is inside it, and focus goes back to the file shown.

Keyboard

KeysAction
EscClose (asks first when a form has unsaved changes). Inspector: only while focus is inside it.
Ctrl + Enter/⌘ + EnterSave the form from any field.
J/KNext / previous record (not while typing in a field).
←/→/Home/EndOn the resize handle: wider / narrower (Shift for bigger steps), min / max.
TabMoves through the panel; focus stays inside a modal drawer and returns to what opened it.

Accessibility

  • role="dialog", named by the header title and described by its description. A modal drawer makes the page behind inert and traps focus; modal={false} (an inspector) does neither, and Escape then works only while focus is inside it.
  • On open, focus goes to the element marked data-autofocus, else the first field of a SideDrawerForm (never on touch screens), else the panel itself so screen readers read its title. On close it returns to the opener (or finalFocus).
  • The resize handle is a labeled separator with aria-valuenow, and works with the arrow keys, Home / End and a double-click; Escape cancels a drag. It is hidden under 640 px, where the panel is full width.
  • notify() writes into a polite live region inside the panel, so "Saved" is announced even from a modal drawer. A close guard that keeps the drawer open leaves focus where it is: show your own confirmation so people know why.
  • Under reduced motion the panel fades in place instead of sliding.

SideDrawer

PropTypeDefaultDescription
modalboolean | "trap-focus"trueDetermines if the drawer enters a modal state when open. - true: user interaction is limited to just the drawer: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled. - false: user interaction with the rest of the document is allowed. - 'trap-focus': focus is trapped inside the drawer, but document page scroll is not locked and pointer interactions outside of it remain enabled.
defaultOpenbooleanfalseWhether the drawer is initially open. To render a controlled drawer, use the open prop instead.
onOpenChange((open: boolean, details?: SideDrawerChangeDetails) => void)NoneCalled when the drawer opens or closes. details is Base UI's event details; it is undefined when a close guard settled later (e.g. after "Discard?") or requestClose closed it.
dir"ltr" | "rtl"Base UI's DirectionProvider, then the page's dirReading direction: the panel slides from the inline end (right in "ltr", left in "rtl").
labelsPartial<SideDrawerLabels>defaultSideDrawerLabelsEvery other string, for translation: labels={{ close: "…" }}; omitted keys keep the English of defaultSideDrawerLabels. All 6 keys of SideDrawerLabels are listed in the key table under the props table.
open / defaultOpenbooleanfalseControlled / initial open state.
disablePointerDismissalbooleanmodal === falseKeep it open on outside presses.
handleSideDrawerHandleNoneFrom createSideDrawerHandle(): open it from triggers rendered elsewhere.
SideDrawerLabels keys and English defaults (6)
Pass any key in labels; the rest keep the defaults of defaultSideDrawerLabels.
KeyEnglish default
closeClose
escapeKeyEsc
resizeResize panel
resizeValue(width) => `${Math.round(width)} pixels wide`
resizeWiderMake panel wider
resizeNarrowerMake panel narrower

SideDrawerContent

PropTypeDefaultDescription
childrenReactNodeNoneThe sheet's content: usually DrawerHeader, DrawerBody and DrawerFooter.
containerHTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null<body>Where to portal the drawer (defaults to <body>).
viewportClassNamestringNoneAdds extra classes to the full-screen positioning layer.
backdropClassNamestringNoneClass for the dimmed scrim behind a modal drawer.
insetbooleantrueFloat the panel off the screen edges with a full radius, a lit leading edge and an accent aura spilling onto the page (like an iOS 26 sheet). false attaches it flush to the edge (the old look).
stateLightbooleantrueLights the panel while a SideDrawerForm inside it saves (accent glow) or has saved or failed (green, red): a lit edge and a light pool on the glass's own layer (data-state on the panel). The seal and the lit leading edge stay.
sizeSideDrawerSize"md"Width: sm 24rem · md 32rem · lg 40rem · xl 48rem. Full width under 640px.
resizablebooleanfalseA handle on the free edge to drag (or arrow-key) the width. Hidden under 640px.
defaultWidthnumberNoneStarting width in px when resizable (instead of size).
minWidthnumber320Sets the narrowest width in px when resizing.
maxWidthnumberNoneWidest width in px when resizing (never more than the screen minus 3rem).
storageKeystringNoneRemember the resized width under this key (localStorage, per browser).
onWidthChange((width: number | null) => void)NoneCalled when a resize ends (pointer up, a key press, a reset). null = back to size.
publishEdgebooleanfalsePublish the panel's width as --sheen-side-drawer-right (or -left) on <html> while it is open, so fixed UI in that corner (a toast stack) can move out of its way. Off by default: an inherited custom property on the root element restyles the whole document on every open and close (200 to 290 ms on a 4x-throttled phone for a 3,500-element page), and nothing in SheenUI reads it.
initialFocusBase UI initialFocussmartDefault: [data-autofocus], else the form’s first field (not on touch), else the panel.
finalFocusBase UI finalFocusthe openerSets where focus goes after closing.
PropTypeDefaultDescription
childrenReactNodeNoneBelow the title row: Tabs, filters, a toolbar.
titleReactNodeNoneThe drawer's name (rendered as its accessible title).
descriptionReactNodeNoneOne line under the title (rendered as the accessible description).
leadingReactNodeNoneShows an avatar or icon before the title.
statusReactNodeNoneNext to the title: a status Badge, a count.
actionsReactNodeNoneShows the buttons before the ×: Edit, a ⋯ menu.
showClosebooleantrueShows the × close button in the header.
SideDrawerBody scrollRefRef<HTMLDivElement>NoneThe scrolling element. Scroll shadows show at edges with more to scroll.
SideDrawerFooter startReactNodeNoneContent on the inline start (hint, record navigation); children sit at the end.
SideDrawerBody wrapperClassNamestringNoneClass for the outer wrapper (holds the scroll shadows).

useSideDrawer() · useSideDrawerCloseGuard()

PropTypeDefaultDescription
notify(message: ReactNode | null, { announce?, duration? }) => void2600 msA check and the message next to the header’s title, announced politely. For actions that keep the drawer open, where a corner toast would cover the header. null clears it.
requestClose({ force? }) => Promise<boolean>NoneClose through the close guards (force skips them). Resolves true when it closed.
open / side / dir / modalboolean / "left" | "right" / "ltr" | "rtl" / boolean | "trap-focus"NoneState of the surrounding drawer (null outside one).
useSideDrawerCloseGuard(guard)() => boolean | Promise<boolean>NoneAsked before every close (×, Escape, scrim, swipe, Cancel). Return a confirm() promise to ask.

SideDrawerForm

PropTypeDefaultDescription
initialValues (required)TValuesNoneStarting values. Read once (give the form a key to reset it for another record).
validate((values: TValues) => SideDrawerFormValidateResult<TValues>)NoneReturn a message per invalid field. Runs on submit, then again as fields are fixed.
onSubmit (required)(values: TValues) => SideDrawerFormSubmitResult<TValues> | Promise<SideDrawerFormSubmitResult<TValues>>NoneSave. Return or resolve { errors } / { error } to show server-side problems, or throw.
onSuccess((values: TValues) => void)NoneAfter a successful save (before the drawer closes / returns to the view).
onCancel(() => void)NoneAfter Cancel (once any discard question is answered).
closeOnFinishbooleantrueClose the drawer after a successful save (or Cancel). Inside SideDrawerDetail it returns to the view instead.
successToastReactNodeNoneToast title after a successful save (needs a <ToastProvider> above); announced when confirmed inline.
successFeedback"inline" | "auto" | "toast""auto"How a successful save is confirmed. "auto": a toast when the drawer closes, "✓ Saved" next to the title when it stays open (inside SideDrawerDetail, or closeOnFinish={false}).
successSealbooleanfalseConfirm a successful save with a seal: the form dims, a check in a success-lit disc folds in and the panel closes (or returns to the view) about a second later, with the successToast. With reduced motion the seal only fades in.
confirmDiscardbooleantrueAsk before throwing away changes.
submitLabelReactNodeNoneShorthand for labels.save.
cancelLabelReactNodeNoneShorthand for labels.cancel.
children (required)(form: SideDrawerFormApi<TValues>) => ReactNodeNoneThe fields. Receives the form API.
footerStartReactNodeNoneExtra footer content on the inline start (replaces the "Unsaved changes" hint).
bodyClassNamestringNoneAdds extra classes to the scrolling body.
labelsPartial<SideDrawerFormLabels>defaultSideDrawerFormLabelsEvery other string, for translation: labels={{ save: "…" }}; omitted keys keep the English of defaultSideDrawerFormLabels. All 12 keys of SideDrawerFormLabels are listed in the key table under the props table.
SideDrawerFormLabels keys and English defaults (12)
Pass any key in labels; the rest keep the defaults of defaultSideDrawerFormLabels.
KeyEnglish default
saveSave
savingSaving…
cancelCancel
unsavedUnsaved changes
shortcutto save
errorSummary(count) => (count === 1 ? "There is 1 problem to fix" : `There are ${count} problems to fix`)
discardTitleDiscard unsaved changes?
discardDescriptionYour edits will be lost. This can’t be undone.
discardDiscard
keepEditingKeep editing
saveFailedCouldn’t save your changes. Please try again.
savedSaved

SideDrawerDetail

PropTypeDefaultDescription
titleReactNodeNoneShows the record's name in the header.
titleTextstringNonePlain-text title for announcements when title is not a string.
subtitleReactNodeNoneShows text under the title, such as an email or a date.
avatarReactNodeNoneShows an Avatar or icon before the title.
statusReactNodeNoneShows content next to the title, usually a Badge.
recordIdstringNoneAn id shown as a copyable chip under the title.
recordIdLabelstringNoneWhat the id is, for its accessible name ("Order ID").
actionsReactNodeNoneAdds extra header buttons, before Edit.
menuReactNodeNoneMenuItem elements for the ⋯ menu (Duplicate, Archive, Delete…).
editablebooleanon when there is an editor or onEditShow the Edit button.
onEdit(() => void)NoneCalled when Edit is pressed (before switching to the editor, if any).
editorReactNodeNoneShown in place of the details while editing: a SideDrawerForm.
modeSideDrawerDetailModeNoneSets the current mode, "view" or "edit", when controlled.
defaultModeSideDrawerDetailMode"view"Sets the starting mode when uncontrolled.
onModeChange((mode: SideDrawerDetailMode) => void)NoneCalled when the mode changes (Edit pressed, Cancel, a successful save).
tabsSideDrawerDetailTab[]NoneSections as tabs (list in the header, panels in the body).
tabstringNoneSets the active tab's value when controlled.
defaultTabstringthe firstSets the starting tab when uncontrolled.
onTabChange((tab: string) => void)NoneCalled when another tab is chosen.
childrenReactNodeNoneBody content when there are no tabs.
footerReactNodeNoneExtra footer content on the end side (view mode).
navigationSideDrawerRecordNavPropsNoneControls for moving to the previous or next record.
recordKeystring | numberNoneIdentity of the record: changing it slides the content and announces the move.
loadingbooleanfalseThe record is loading: the body shows a skeleton.
errorReactNodeNoneLoading failed: a message (or true), with Retry when onRetry is set.
onRetry(() => void)NoneCalled when Retry is pressed (the button shows only when this is set).
emptybooleanfalseNo record to show.
labelsPartial<SideDrawerDetailLabels>defaultSideDrawerDetailLabelsEvery other string, for translation: labels={{ edit: "…" }}; omitted keys keep the English of defaultSideDrawerDetailLabels. All 11 keys of SideDrawerDetailLabels are listed in the key table under the props table.
bodyClassNamestringNoneAdds extra classes to the scrolling body.
SideDrawerDetailLabels keys and English defaults (11)
Pass any key in labels; the rest keep the defaults of defaultSideDrawerDetailLabels.
KeyEnglish default
editEdit
moreActionsMore actions
editingEditing
loadingLoading…
sectionsSections
errorTitleCouldn’t load this record
retryTry again
emptyTitleNothing selected
emptyDescriptionPick a record to see its details here.
moved(title, position) => `${title}, ${position}`
copynested object: takes the keys of CopyLabels; empty here, so its own English defaults apply

SideDrawerRecordNav

PropTypeDefaultDescription
index (required)numberNone0-based index of the record shown.
count (required)numberNoneHow many records there are to walk through.
onIndexChange (required)(index: number) => voidNoneCalled with the new 0-based index when the person moves to another record.
keyboardShortcutsbooleantrueJ (next) / K (previous) while focus is in the drawer and not in a text field.
labelsPartial<SideDrawerRecordNavLabels>defaultSideDrawerRecordNavLabelsEvery other string, for translation: labels={{ previous: "…" }}; omitted keys keep the English of defaultSideDrawerRecordNavLabels. All 5 keys of SideDrawerRecordNavLabels are listed in the key table under the props table.
classNamestringNoneAdds extra classes to the navigation.
SideDrawerRecordNavLabels keys and English defaults (5)
Pass any key in labels; the rest keep the defaults of defaultSideDrawerRecordNavLabels.
KeyEnglish default
previousPrevious
nextNext
previousKeyK
nextKeyJ
position(position, count) => `${position.toLocaleString()} of ${count.toLocaleString()}`

DescriptionList · DescriptionItem

PropTypeDefaultDescription
layoutDescriptionListLayout"inline""inline" (default): label left, value right. "stacked": label above value.
variant"glass" | "plain""plain""plain" (default): no surface. "glass": its own glass card.
dividersbooleantrueDraws a hairline between rows.
size"sm" | "md""md"Sets the row text: "sm" 13px, "md" 14px (default).
itemsDescriptionListEntry[]NoneWorks as shorthand for a list of DescriptionItem children.
childrenReactNodeNoneHolds DescriptionItem rows, shown after any items.
labelsPartial<DescriptionListLabels>defaultDescriptionListLabelsEvery other string, for translation: labels={{ copy: "…" }}; omitted keys keep the English of defaultDescriptionListLabels. All 5 keys of DescriptionListLabels are listed in the key table under the props table.
label (required)ReactNodeNoneHolds the term, rendered as the <dt>.
copyValuestringNoneShows a copy button that copies this text.
copyLabelstringlabels.copyValue(label) when the label is textSets the accessible name of the copy button.
hintReactNodeNoneShows small muted text under the value.
labelClassNamestringNoneAdds a class name to the <dt> element.
valueClassNamestringNoneAdds a class name to the <dd> element.
DescriptionListLabels keys and English defaults (5)
Pass any key in labels; the rest keep the defaults of defaultDescriptionListLabels.
KeyEnglish default
copyCopy
copiedCopied
failedCouldn’t copy. Select the text and copy it manually.
emptyNot set
copyValue(label) => `Copy ${label.toLowerCase()}`

CopyButton props

PropTypeDefaultDescription
value (required)stringNoneThe text that is copied.
labelstringlabels.copySets the accessible name, e.g. "Copy email address".
size"sm" | "md""sm""sm" 28px (rows, chips) or "md" 36px. Both grow to a 44px hit area on touch screens.
labelsPartial<CopyLabels>defaultCopyLabelsOverride the "Copy", "Copied" and failure strings (i18n). Every other string, for translation: labels={{ copy: "…" }}; omitted keys keep the English of defaultCopyLabels. All 3 keys of CopyLabels are listed in the key table under the props table.
onCopied((value: string) => void)NoneCalled after a successful copy.
CopyLabels keys and English defaults (3)
Pass any key in labels; the rest keep the defaults of defaultCopyLabels.
KeyEnglish default
copyCopy
copiedCopied
failedCouldn’t copy. Select the text and copy it manually.

CopyChip props

PropTypeDefaultDescription
value (required)stringNoneThe text shown (in mono) and copied, e.g. an id.
labelstringNoneWhat the value is, for the accessible name: "Order ID" → "Copy Order ID ord_8Hk2Qx".
displaystringNoneShown instead of value (the full value is still copied).
labelsPartial<CopyLabels>defaultCopyLabelsOverride the "Copy", "Copied" and failure strings (i18n). Every other string, for translation: labels={{ copy: "…" }}; omitted keys keep the English of defaultCopyLabels. All 3 keys of CopyLabels are listed in the key table under the props table.
onCopied((value: string) => void)NoneCalled after a successful copy.

SideDrawerBody props

PropTypeDefaultDescription
scrollRefRef<HTMLDivElement>NoneReceives the ref to the scrolling element.
wrapperClassNamestringNoneClass for the outer wrapper (holds the scroll shadows).

SideDrawerFooter props

PropTypeDefaultDescription
startReactNodeNoneContent on the inline start: a hint ("Unsaved changes"), record navigation.

SideDrawerNotice props

PropTypeDefaultDescription
classNamestringNoneAdds extra classes to the notice.
variant"inline" | "badge""inline""inline": check + message, for the title row. "badge": just the check, pinned to the corner of an avatar / icon (its parent must be positioned).

All exports on this page

Show all 31 exports
  • CopyButton — A ghost icon button that copies value to the clipboard and swaps its icon for a check mark.
  • CopyChip — A small mono pill that copies its value: ids, keys, hashes.
  • CopyIcon — The 16px "copy" (two sheets) icon used by CopyButton.
  • DescriptionItem — One label / value pair of a DescriptionList: a <div> holding a <dt> and a <dd>.
  • DescriptionList — DescriptionList: key / value pairs for detail views (a record in a side drawer, an order summary, settings read-outs), as a real <dl>.
  • SideDrawer — SideDrawer: a glass panel that slides in from the inline end of the screen (the right in left-to-right pages, the left in right-to-left ones) to edit a record or show its details without leaving the page.
  • SideDrawerBody — The scrolling part.
  • SideDrawerClose — Closes the drawer (through the close guards).
  • SideDrawerCloseButton — The × button, with an "Esc" tooltip.
  • SideDrawerContent — The glass panel of a SideDrawer, portalled to the end of the body.
  • SideDrawerDescription — Muted helper text under the title.
  • SideDrawerDetail — SideDrawerDetail: the "record details" pattern for a SideDrawerContent.
  • SideDrawerEditContext — Provided by SideDrawerDetail around its editor: Cancel / Save in a SideDrawerForm return to the view instead of closing the drawer.
  • SideDrawerFooter — Sticky footer: start on the inline start (a hint such as "Unsaved changes", record navigation), the buttons (children) on the other end.
  • SideDrawerForm — SideDrawerForm: the "edit in a side panel" pattern, wired up.
  • SideDrawerHeader — Sticky header: an optional leading slot, the title with its status, the actions and a close button, with the description underneath.
  • SideDrawerNotice — The visible half of useSideDrawer().notify(): a check and a short message that pops in next to the title and fades away.
  • SideDrawerRecordNav — Previous / next record controls for a SideDrawerFooter: ↑ / ↓ buttons, "3 of 312", and J (next) / K (previous) keys.
  • SideDrawerTitle — The drawer's heading.
  • SideDrawerTrigger — The element that opens a SideDrawer (a <button> by default; use render={<Button />} for a SheenUI button).
  • defaultCopyLabels — Default English strings of CopyLabels; spread it and override single keys to reword.
  • defaultDescriptionListLabels — Default English strings of DescriptionListLabels; spread it and override single keys to reword.
  • defaultSideDrawerDetailLabels — Default English strings of SideDrawerDetailLabels; spread it and override single keys to reword.
  • defaultSideDrawerFormLabels — Default English strings of SideDrawerFormLabels; spread it and override single keys to reword.
  • defaultSideDrawerLabels — Default English strings of SideDrawerLabels; spread it and override single keys to reword.
  • defaultSideDrawerRecordNavLabels — Default English strings of SideDrawerRecordNavLabels; spread it and override single keys to reword.
  • sideDrawerIconButtonClass — Ghost icon button used in drawer headers / footers: 36px, 44px hit area on touch screens.
  • sideDrawerSizes — Width of each size, in rem.
  • useCopyToClipboard — const { status, copied, copy } = useCopyToClipboard().
  • useSideDrawer — The surrounding SideDrawer: open, requestClose() (runs the close guards), side, dir, modal and notify(message).
  • useSideDrawerCloseGuard — Ask before the drawer closes.

When to use the side drawer

  • Use it as a slide-over panel for an order or issue detail peek in a table, where clicking a row slides a panel in from the right and the list stays visible behind it, with previous and next navigation.
  • Use it for editing a record, such as a user profile, with the validated SideDrawerForm, an inline error summary and a close guard asking Discard unsaved changes before Escape or the scrim closes it.
  • Use modal={false} for an inspector panel that leaves the page usable: there is no scrim or focus trap, and outside clicks do not close it.
  • Skip it when you need a bottom sheet for phones or a plain navigation menu, which Drawer covers, and use Dialog for a small centered prompt rather than a record panel.
  • Pair it with DescriptionList and Tabs for detail bodies, DataTable for the list that opens it, and AlertDialog or the notify function when saving needs confirmation feedback.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .