Dialog
A modal component that appears in the center of the screen to draw user attention and contains title, body, and footer.
<overlay>Installation
Install dependencies
Copy the code below and paste it in
The Dialog in @seed-design/lynx-react wraps @lynx-js/lynx-ui-dialog. The Registry's DialogContent assembles Positioner, Backdrop, and Header internally, and DialogAction provides ActionButton and close action together.
Usage
The Registry's DialogContent assembles Positioner, Backdrop, and Header internally. DialogTrigger must be placed outside Content to open the Dialog by tapping. The showCloseButton of DialogContent defaults to true and renders a close ActionButton in the header. If you don't need a close button, set showCloseButton={false}.
DialogBody is rendered as native <scroll-view scroll-y> and scrolls vertically within the maximum height of the Content. DialogAction accepts ActionButton props and renders with close action.
Props
DialogRoot
Prop
Type
DialogTrigger
Prop
Type
DialogContent
Prop
Type
title?React.ReactNodedescription?React.ReactNodechildren?React.ReactNodecontainer?string | undefinedoverlayLevel?1 | 2 | 3 | 4 | undefinedDialogBody
Prop
Type
bg?(string & {}) | ScopedColorBg | ScopedColorPalette | ScopedColorBanner | undefinedbackground?(string & {}) | ScopedColorBg | ScopedColorPalette | ScopedColorBanner | undefinedcolor?(string & {}) | ScopedColorPalette | ScopedColorFg | undefinedborderColor?(string & {}) | ScopedColorPalette | ScopedColorStroke | undefinedborderWidth?0 | (string & {}) | 1 | undefinedborderTopWidth?0 | (string & {}) | 1 | undefinedborderRightWidth?0 | (string & {}) | 1 | undefinedborderBottomWidth?0 | (string & {}) | 1 | undefinedborderLeftWidth?0 | (string & {}) | 1 | undefinedborderRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderTopLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderTopRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedwidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedminWidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedmaxWidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedheight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedminHeight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedmaxHeight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedtop?0 | (string & {}) | undefinedleft?0 | (string & {}) | undefinedright?0 | (string & {}) | undefinedbottom?0 | (string & {}) | undefinedpadding?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedp?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingX?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpx?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingY?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpy?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingTop?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "safeArea" | undefinedpt?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "safeArea" | undefinedpaddingRight?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpr?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpaddingBottom?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "safeArea" | undefinedpb?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | "safeArea" | undefinedpaddingLeft?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedpl?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefineddisplay?(string & {}) | "flex" | "none" | undefinedposition?(string & {}) | "relative" | "absolute" | "fixed" | undefinedoverflowX?(string & {}) | "visible" | "hidden" | undefinedoverflowY?(string & {}) | "visible" | "hidden" | undefinedzIndex?Property.ZIndex | undefinedflexGrow?boolean | Property.FlexGrow | undefinedflexShrink?boolean | Property.FlexShrink | undefinedflexDirection?(string & {}) | "row" | "column" | "rowReverse" | "columnReverse" | undefinedflexWrap?boolean | "nowrap" | "wrap" | undefinedjustifyContent?(string & {}) | "flexStart" | "flexEnd" | "center" | "spaceBetween" | "spaceAround" | undefinedjustifySelf?Property.JustifySelf | undefinedalignItems?(string & {}) | "flexStart" | "flexEnd" | "center" | "stretch" | undefinedalignContent?(string & {}) | "flexStart" | "flexEnd" | "center" | "stretch" | undefinedalignSelf?(string & {}) | "flexStart" | "flexEnd" | "center" | "stretch" | undefinedgap?0 | (string & {}) | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedstyle?CSSProperties | undefinedchildren?React.ReactNodeclassName?string | undefinedDialogFooter
DialogAction
Prop
Type
icon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefinedprefixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefinedsuffixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefinedflexGrow?boolean | Property.FlexGrow | undefinedchildren?React.ReactNodebindtap?EventHandler<BaseTouchEvent<Target>> | undefinedmain-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefinedaccessibility-label?string | undefinedaccessibility-element?boolean | undefinedaccessibility-traits?"disabled" | "none" | "text" | "image" | "button" | "link" | "header" | "search" | "selected" | "playable" | "keyboard" | "summary" | "updating" | "adjustable" | "tabbar" | undefinedExamples
Trigger
Tapping <DialogTrigger> opens the Dialog. Lynx does not support React's asChild, and Trigger renders a native view wrapping child elements.
Controlled
To open and close the Dialog in ways other than Trigger, control state with open and onOpenChange.
Size
You can change the Dialog width with the size prop of <DialogRoot>. "medium" is the default and "large" is supported. For both sizes, small screens use the recipe's viewport-based width, and larger screens apply the Dialog token's maximum width for each size. Content height is limited by the recipe's maximum height.
Body
<DialogBody> is a body slot with the seed-dialog__body selector applied. It is rendered as native <scroll-view scroll-y> and scrolls vertically within the maximum height of Content. The default horizontal padding is provided by the recipe's body token (x6).
Unlike the web version, Lynx does not display a header divider or bottom fade mask by observing overflow state.
Custom Body
<DialogBody> accepts existing Lynx styled props. You can redefine height, min-height, and alignment with className or style. If you need to override the Recipe's default padding, specify paddingLeft and paddingRight directly in style to avoid being affected by CSS load order. Only explicitly specify when removing the default horizontal padding to place full-bleed content.
Show Close Button
The Registry's DialogContent supports showCloseButton and defaults to true. Setting it to false hides the close ActionButton in the header, allowing you to provide explicit close action in the footer and other areas.
Footer Layout
DialogFooter provides only flex layout. Button arrangement is constructed directly by specifying flex-direction, justify-content, gap, and others on child view.
Prevent Close
Lynx's DialogAction does not support the preventDefault() method from React events. You can prevent closing by making Dialog controlled and conditionally ignoring onOpenChange(false).
onOpenChange Details
Lynx's onOpenChange passes only the changed open value. The second argument details.reason from the React version is not supported. If you need the close reason, record it in a separate state in the event handlers of app-owned buttons and Trigger.
Confirm Before Close
Unlike React examples, Lynx does not support showing confirmation Dialogs for closeButton, escapeKeyDown, interactOutside separately. Since Lynx callbacks alone cannot distinguish close reasons, for actions that need confirmation, open the confirmation Dialog first in the handler of an app-owned button and directly control the open of the original Dialog.
Portalled
When you specify container for DialogContent, it renders on the native overlay layer. You can specify the display order of the overlay layer with overlayLevel.
Responsive
Automatic switching components like React's ResponsiveDialog are not provided in Lynx. Directly select Dialog and BottomSheet in your app based on screen size, or connect the same controlled state to both components.
Web Version Differences
| Item | Web | Lynx |
|---|---|---|
| User events | onClick | bindtap or public callback |
| Rendering elements | HTML elements and Portal | native <view>, <text>, <scroll-view> and overlay |
| State prop | open, defaultOpen, onOpenChange | Same. Internally connected to lynx-ui-dialog's show, defaultShow, onShowChange |
| Trigger composition | asChild supported | Not supported. Trigger renders a view wrapping child elements |
| Body slot | DialogBody provided | DialogBody provided. Uses native <scroll-view scroll-y> and seed-dialog__body selector with default horizontal padding from recipe body token(x6) |
| Close button | showCloseButton supported | Default support in Registry's DialogContent. Hidden with showCloseButton={false} |
| Close reason | details.reason in onOpenChange | Only boolean open value provided |
| Portal / overlay | Portal component | DialogContent's container, overlayLevel |
| Responsive Dialog | ResponsiveDialog provided | Not provided. Dialog and BottomSheet combined directly in app |
| Mount control | lazyMount, unmountOnExit | forceMount supported |
| Imperative ref API | None | Not supported |