Dialog
A headless Dialog (modal) component for ReactLynx. It provides backdrop overlay, open/close state management, and enter/exit animations via Presence.
The dialog component. Have a customizable background mask layer.
Basic Usage
Structure
<DialogRoot>
<DialogView>
<DialogBackdrop />
<DialogContent />
</DialogView>
</DialogRoot>
API
DialogRoot
The root component of the Dialog, containing all of its child components.
Typeboolean
Display debug logs. Open it when you find a bug.
Typeboolean·Defaultfalse
Determines whether the dialog should be shown by default. Use this property means the Dialog is uncontrolled.
Typeboolean·Defaultfalse
Mount the popper and render the content even when it's not shown. At this time, the internal state is "closed".
Type() => void
Triggered when the popper is actually closed and the potential animation is finished.
Type() => void
Triggered when the popper is actually show and the potential animation is finished.
Type(open: boolean) => void
Triggered when the dialog is about to be closed, which can be triggered by clicking the backdrop or via a close button. In controlled mode (when show is provided), you should use this handler to update the state that controls the dialog's visibility. In uncontrolled mode, this handler is optional and is called before the dialog's internal state is updated.
Typeboolean
Whether to show the popper. If this property is not set, the popper will be in controlled mode, meaning the defaultShow property will take no effects. And you have to control behavior of clicking close button and backdrop.
TypeReactNode | (status: {animating?: boolean, closed?: boolean, entering?: boolean, leaving?: boolean, open?: boolean}) => ReactNode
children
State-based styling & rendering
This component exposes each of its internal states through two interchangeable channels, and the table below maps them one-to-one:
- CSS className — a class like
ui-<state> is toggled on the root node, so you can style it with selectors such as .ui-<state> { ... }. - Render-prop field — when
children is a function, the same state is passed in via children({ <state>: boolean, ... }) for runtime-driven rendering.
ui-animatingRender Propanimating·Typeboolean
The popper is doing the animations. Takes effect when transition:true.
Applied when `status.animating` is true.
ui-closedRender Propclosed·Typeboolean
The popper is closed.
If it's force mounted, the initial status will be closed.
Applied when `status.closed` is true.
ui-enteringRender Propentering·Typeboolean
The popper is performing the entering animation. Takes effect when transition:true.
Applied when `status.entering` is true.
ui-leavingRender Propleaving·Typeboolean
The popper is performing the leaving animation. Takes effect when transition:true.
Applied when `status.leaving` is true.
ui-openRender Propopen·Typeboolean
The popper is opened.
Applied when `status.open` is true.
DialogBackdrop
The backdrop mask of the dialog.
Typeboolean·Defaulttrue
Determines whether clicking on the backdrop closes the dialog.
This prop acts as a behavior switch for the backdrop's click event.
When true, clicking the backdrop will trigger the onClose callback and close the dialog if the dialog is in uncontrolled mode (when show is not provided).
When false, clicking the backdrop will have no effect.
Typeboolean
If the content needs a delayed first screen to do first render, you need to set this property to true.
TypeViewProps
DialogBackdrop supports original view props to be directly spread in this prop.
Type() => void
Triggered when the backdrop is clicked.
Typeboolean
If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'
DialogView
View container. When 'container' is set correctly, the underlying layer will be replaced with overlay; otherwise, it will be a regular view. When the underlying layer is overlay, the 'level' property can be used to control the hierarchical relationship. For a regular view, use 'z-index' to control the hierarchical relationship. If this dialog needs to be used outside of LynxView, consider enabling overlay.
Typestring
If you want to use the poppers outside of the LynxView, you need to set this property. The value is the name of the native container.
Typeboolean
Display debug logs. Open it when you find a bug.
TypeViewProps | OverlayProps
Additional props that will be spread to the underlying OverlayView element
Type1 | 2 | 3 | 4
Only works when the 'container' is set to non-empty string. Adjust nearby elements display level.
Typeboolean
If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'
TypeReactNode | (status: {open?: boolean, closed?: boolean, leaving?: boolean, entering?: boolean, animating?: boolean}) => ReactNode
children
State-based styling & rendering
This component exposes each of its internal states through two interchangeable channels, and the table below maps them one-to-one:
- CSS className — a class like
ui-<state> is toggled on the root node, so you can style it with selectors such as .ui-<state> { ... }. - Render-prop field — when
children is a function, the same state is passed in via children({ <state>: boolean, ... }) for runtime-driven rendering.
ui-openRender Propopen·Typeboolean
The popper is opened.
Applied when `status.open` is true.
ui-closedRender Propclosed·Typeboolean
The popper is closed.
If it's force mounted, the initial status will be closed.
Applied when `status.closed` is true.
ui-leavingRender Propleaving·Typeboolean
The popper is performing the leaving animation. Takes effect when transition:true.
Applied when `status.leaving` is true.
ui-enteringRender Propentering·Typeboolean
The popper is performing the entering animation. Takes effect when transition:true.
Applied when `status.entering` is true.
ui-animatingRender Propanimating·Typeboolean
The popper is doing the animations. Takes effect when transition:true.
Applied when `status.animating` is true.
DialogContent
The main content of the dialog.
Typeboolean
If the content needs a delayed first screen to do first render, you need to set this property to true.
TypeViewProps
DialogContent supports original view props to be directly spread in this prop.
Typeboolean
If set to true, the className will has the transition classes like 'ui-entering', 'ui-leaving', 'ui-animating'