Skip to content

Glass Modal Dialog for React

A strong-glass React modal dialog that springs in with Motion, with focus trapping, Escape to close and focus return handled by Base UI.

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

Project members

Maya and Jonas are not on the team yet.

  • Dialog
  • DialogClose
  • DialogTitle
  • DialogFooter
  • DialogHeader
  • +7 more
  • +4 more

Edit profile

Files to copy

5 folders · 9 files · 4 packages
From theme/src/
  • components/dialog/
  • components/drawer/parts/sheet.tsx
  • hooks/{use-latest.ts, use-media-query.ts}
  • lib/{cn.ts, form.ts, modal-flag.ts, modal-tab-trap.ts, popup-motion.ts, state-light.tsx}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/dialog.jsonRegistry item: dialog. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/button/
  • components/input/
  • components/spinner/
  • components/toast/
  • hooks/{use-direction.ts, use-magnetic.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/field-size.ts
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/input.json https://lokendra-builds.github.io/sheenui/r/toast.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Controlled, with a form

Open state lives in your component, so any button (or code) can open it and a successful submit can close it.

Bottom sheet on phones

mobile='sheet' presents the dialog as a bottom sheet under 640px wide: full width, a drag handle you can swipe down, content scrolling inside a 85dvh cap, safe-area padding. Escape, the close button and focus return work as before. The default, 'popup', keeps the centred window. Press “Preview on a phone” to try it on a desktop screen (or narrow the window).

Props

PropTypeDefaultDescription
mobileMobilePresentation"popup"How the window opens on a phone-width screen (max-width: 640px): "popup" is the usual centred window; "sheet" is a bottom sheet with a drag handle, swipe-down to dismiss, a scrollable body capped at 85 dvh and home-indicator padding. Focus is trapped and returned and Escape closes in both.
Dialog open / defaultOpenbooleanfalseControlled or uncontrolled open state.
Dialog onOpenChange(open) => voidNoneCalled when the dialog opens or closes.
DialogTrigger / DialogClose renderReactElementNoneRender as your own element, e.g. render={<Button />}.
DialogContent initialFocus / finalFocusref | function | booleanfirst control / triggerWhere focus goes when the dialog opens and closes (Base UI).

DialogContent props

PropTypeDefaultDescription
childrenReactNodeNoneThe dialog body: usually DialogHeader, your content and DialogFooter.
showClosebooleantrueShow the × button in the top-right corner.
labelsPartial<DialogLabels>defaultDialogLabelsTranslate the × button: { close: "Schließen" }. Every other string, for translation: labels={{ close: "…" }}; omitted keys keep the English of defaultDialogLabels. Its only key is listed in the key table under the props table.
stateLightbooleanfalseLights the open window with a soft accent glow: a lit edge and a light pool on the glass's own layer (data-state="on"; set data-state to "working", "success", "warning" or "error" to change it). Off with reduced transparency and forced colours. The window scrolls, so its outer aura is clipped: the glow reads inside the edge.
containerHTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | nullthe end of document.bodyWhere the window is portalled. Pass an element to keep it inside a region (a stage, a preview) instead of the end of the body.
backdropbooleantrueRender the dimmed scrim behind the window. Turn it off for a non-modal dialog (modal={false} on Dialog), where the page stays usable.
DialogLabels keys and English defaults (1)
Pass any key in labels; the rest keep the defaults of defaultDialogLabels.
KeyEnglish default
closeClose

Keyboard

KeysAction
Enter/SpaceOpen it from the trigger; focus moves inside.
Tab/Shift + TabCycle through the controls inside; focus cannot leave while it is open.
EscapeClose it and return focus to the trigger.

Accessibility

  • Built on Base UI's Dialog: role="dialog", named by DialogTitle and described by DialogDescription; the page behind is inert while it is open.
  • Focus is trapped, starts on the first control (or initialFocus) and returns to the trigger on close.
  • Always render a DialogTitle; showClose adds a labeled close button. Under reduced motion the dialog only fades.

All exports on this page

  • Dialog — Glass dialog: a modal window that blocks the page until the person answers or dismisses it.
  • DialogClose — A button inside the dialog that closes it (a "Cancel" or "Done" action in DialogFooter).
  • DialogContent — The glass window of a Dialog, portalled to the end of the body with a dimmed scrim behind it.
  • DialogDescription — Muted helper text under the title.
  • DialogFooter — Layout wrapper for the dialog's actions: a column on phones (primary action last in the DOM, so it is first on screen) and a right-aligned row from sm up.
  • DialogHeader — Layout wrapper for DialogTitle and DialogDescription.
  • DialogTitle — The dialog's heading.
  • DialogTrigger — The element that opens a Dialog.
  • defaultDialogLabels — English defaults of DialogLabels.

When to use Dialog

  • Use Dialog as a glass modal for a short form that blocks the page, such as renaming a project or inviting a teammate, where the person finishes or cancels before going back to the page. Use it as an animated modal in React whenever the content needs the person's full attention.
  • Use it for a details view opened from a table row or a card, with DialogTitle and DialogDescription naming and describing it for screen readers.
  • Use DialogFooter with DialogClose for Cancel and Save actions, and keep the corner close button on with showClose unless the footer already offers a clear exit.
  • Skip it when the person must answer a destructive question, where AlertDialog fits better, or when the content is a side panel you want next to the page, where Drawer fits better.
  • Pair it with Button through the render prop on DialogTrigger, Input and Field for the form inside, and Toast to confirm the result after the dialog closes.

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 .