Dialog
A headless Dialog (modal) component for ReactLynx. It provides backdrop overlay, open/close state management, and enter/exit animations via Presence.You can check the source code to understand how it works, and you're welcome to submit PRs to enhance its capabilities.
The dialog component. Have a customizable background mask layer.
Basic Usage
Structure
Component API
DialogRoot
The root component of the Dialog, containing all of its child components.
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.State-based styling & rendering
This component exposes runtime states through one or both of the following channels. The table lists only the channels available for each state:
- UI variant class — when supported, a class like
ui-<state>is toggled on the corresponding component node for selectors such as.ui-<state> { ... }. - Render-prop field — when supported and
childrenis a function, the state is passed in viachildren({ <state>: boolean, ... })for runtime-driven rendering.
DialogRoot exposes the following render prop states.
| Render Prop | Type | Description |
|---|---|---|
animating | boolean | The popper is doing the animations. Takes effect when transition:true. |
closed | boolean | The popper is closed. If it's force mounted, the initial status will be closed. |
entering | boolean | The popper is performing the entering animation. Takes effect when transition:true. |
leaving | boolean | The popper is performing the leaving animation. Takes effect when transition:true. |
open | boolean | The popper is opened. |
DialogTrigger
The trigger of the dialog. Controls the display of the popper.
true, the component will be in a disabled state and cannot be interacted with.ReactNode or a ReactNode itself.UI variants applied by DialogTrigger based on its render state.
| Class Name | Render Prop | Type | Description |
|---|---|---|---|
| ui-active | active | boolean | Render function state: active. Applied while the composed dialog button is pressed and not disabled. |
| ui-animating | — | boolean | Applied when `status.animating` is true. |
| ui-busy | busy | boolean | Render function state: busy. Applied while the dialog is entering or leaving. |
| ui-closed | — | boolean | Applied when `status.closed` is true. |
| ui-disabled | — | boolean | Applied when the dialog button is explicitly disabled or the dialog is busy. |
| ui-entering | — | boolean | Applied when `status.entering` is true. |
| ui-leaving | — | boolean | Applied when `status.leaving` is true. |
| ui-open | — | boolean | Applied when `status.open` is true. |
DialogBackdrop
The backdrop mask of the dialog.
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.UI variants applied by DialogBackdrop.
| Class Name | Description |
|---|---|
| ui-animating | Applied when `status.animating` is true. |
| ui-closed | Applied when `status.closed` is true. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
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.
UI variants applied by DialogView based on its render state.
| Class Name | Render Prop | Type | Description |
|---|---|---|---|
| ui-animating | animating | boolean | The popper is doing the animations. Takes effect when transition:true. Applied when `status.animating` is true. |
| ui-closed | closed | boolean | The popper is closed. If it's force mounted, the initial status will be closed. Applied when `status.closed` is true. |
| ui-entering | entering | boolean | The popper is performing the entering animation. Takes effect when transition:true. Applied when `status.entering` is true. |
| ui-leaving | leaving | boolean | The popper is performing the leaving animation. Takes effect when transition:true. Applied when `status.leaving` is true. |
| ui-open | open | boolean | The popper is opened. Applied when `status.open` is true. |
DialogContent
The main content of the dialog.
UI variants applied by DialogContent.
| Class Name | Description |
|---|---|
| ui-animating | Applied when `status.animating` is true. |
| ui-closed | Applied when `status.closed` is true. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
DialogClose
The close component of the Dialog, used to close the dialog.
true, the component will be in a disabled state and cannot be interacted with.ReactNode or a ReactNode itself.UI variants applied by DialogClose based on its render state.
| Class Name | Render Prop | Type | Description |
|---|---|---|---|
| ui-active | active | boolean | Render function state: active. Applied while the composed dialog button is pressed and not disabled. |
| ui-animating | — | boolean | Applied when `status.animating` is true. |
| ui-busy | busy | boolean | Render function state: busy. Applied while the dialog is entering or leaving. |
| ui-closed | — | boolean | Applied when `status.closed` is true. |
| ui-disabled | — | boolean | Applied when the dialog button is explicitly disabled or the dialog is busy. |
| ui-entering | — | boolean | Applied when `status.entering` is true. |
| ui-leaving | — | boolean | Applied when `status.leaving` is true. |
| ui-open | — | boolean | Applied when `status.open` is true. |