React

Dialog

A dialog that floats in the center of the screen to capture the user's attention. Used to hold rich content such as forms or scrollable content with a title, body, footer, and close button.

Available since@seed-design/react@2.1.0, @seed-design/css@2.3.0

Alert Dialog

Use Alert Dialog if the purpose is to get user confirmation or warning.

Installation

Default

Includes a default Dialog component that floats in the center of the screen and holds a title, body, and footer.

npx @seed-design/cli@latest add ui:dialog

Responsive

A responsive variant that automatically switches to Bottom Sheet based on viewport.

npx @seed-design/cli@latest add ui:responsive-dialog

Props

DialogRoot

Prop

Type

childrenReact.ReactNode
open?boolean | undefined
defaultOpen?boolean | undefined
onOpenChange?((open: boolean, details?: DialogChangeDetails) => void) | undefined

DialogTrigger

Prop

Type

DialogContent

Prop

Type

title?React.ReactNode
description?React.ReactNode
layerIndex?number | undefined
width?ResponsiveValue<(string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "full"> | undefined
maxWidth?ResponsiveValue<(string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "full"> | undefined

DialogBody

Prop

Type

paddingX?ResponsiveValue<0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText"> | undefined
minHeight?ResponsiveValue<(string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "full"> | undefined
maxHeight?ResponsiveValue<(string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "full"> | undefined
justifyContent?"flex-start" | "flex-end" | "center" | "space-between" | "space-around" | undefined
alignItems?"flex-start" | "flex-end" | "center" | "stretch" | undefined

DialogFooter

Prop

Type

DialogAction

Prop

Type

ResponsiveDialogRoot

Prop

Type

children?React.ReactNode
open?boolean | undefined
defaultOpen?boolean | undefined
onOpenChange?((open: boolean) => void) | undefined

Examples

Trigger

<DialogTrigger> sets the aria-haspopup="dialog" attribute and automatically sets the aria-expanded attribute based on the Dialog's open state. This attribute is useful for assistive technologies like screen readers.

Controlled

You can open and close the Dialog in ways other than Trigger. In this case, use the open prop to control the Dialog's state.

Size

You can change the Dialog's width by setting the size prop on <DialogRoot>. Supports "medium" (480px, default) and "large" (800px). On screens smaller than md, it takes 90% of the viewport width, and on md and above, the maximum width of each size is applied. The content height is limited to 80% of the viewport.

You can also directly control the width by passing width and maxWidth props to <DialogContent>. Use this when you need flexible viewport-based width instead of preset sizes. Since a single value applies to all breakpoints, pass a breakpoint object like width={{ md: "560px" }} to maintain the default width for below md (90% of viewport).

Body

<DialogBody> makes the body area scrollable. When the body is long and scrolls, a divider appears below the header and a fade-out mask is applied at the bottom. The bottom fade mask and padding-bottom are applied only when the Body exceeds the viewport height and creates scroll. If the body is short and does not overflow, the mask is not applied so the last line is not blurred.

Custom Body

You can directly control the body area by passing paddingX, minHeight, maxHeight, justifyContent, and alignItems props to <DialogBody>. Use this to limit scroll height lower than the default cap (80% of viewport), fix height even with short content, or remove horizontal padding to stretch content to the edges.

Show Close Button

You can show the close button in the top right by passing the showCloseButton prop to <DialogContent>. The default value is true.

DialogFooter provides only flex layout, and button arrangement is directly composed with VStack, HStack, etc.

Prevent Close

If you call e.preventDefault() in DialogAction's onClick, the dialog will not close.

onOpenChange Details

details is provided as the second argument to onOpenChange.

reason

When opening (open: true)

  • "trigger": opened via DialogTrigger

When closing (open: false)

  • "closeButton": closed via DialogAction or the top-right close button
  • "escapeKeyDown": ESC key used
  • "interactOutside": click outside area
    • DialogRoot defaults to closeOnInteractOutside={false}. interactOutside can only occur when this option is set to true.
  • "cascadeDismiss": cascading close due to parent layer closing

Confirm Before Close

If you want to prevent accidentally closing content being written, keep open in a controlled state and show a confirmation Alert Dialog while maintaining open for specific reason to ask the user.

Portalled

Portal is rendered to document.body by default.

Responsive

Using ResponsiveDialog automatically switches to Dialog for md and above and to Bottom Sheet for sm and below. Try reducing the viewport to see the switch in action. onOpenChange passes only the open state, and Root options that apply only to Dialog or Bottom Sheet are passed via dialogRootProps and bottomSheetRootProps.

Table of contents