Documentation
Dialog

Dialog

Bundle size
11 KB
0.0.3

Unlike a Toast, the Dialog interrupts the user experience, adding a new step to their navigation journey. It can be used to confirm important actions or to present additional information to the current context.

The Dialog can be triggered from 5 different positions. Clicking outside of it will close it.

Installation

pnpm add @inpulse-ds/dialog

API

Root

Contains all parts of a Dialog.

PropTypeDefault valueRequired
defaultOpenboolean-No
openboolean-No
onOpenChangefunction-No

Trigger

Responsible for opening the Dialog.

PropTypeDefault valueRequired
asChildboolean-No
AttributeValue
[data-state]"open" | "closed"

Content

Abraça todo o conteúdo exibido pelo Dialog.

PropTypeDefault valueRequired
asChildboolean-No
onOpenAutoFocusfunction-No
onCloseAutoFocusfunction-No
onEscapeKeyDownfunction-No
onPointerDownOutsidefunction-No
onInteractOutsidefunction-No
AttributeValue
[data-state]"open" | "closed"

Close

Responsible for closing the Dialog.

PropTypeDefault valueRequired
asChildboolean-No

Title

A title that is announced in an accessible way when a Dialog is opened. If you want to hide the title, wrap it with a <VisuallyHidden asChild>.

PropTypeDefault valueRequired
asChildboolean-No

Description

A description that is announced in an accessible way when a Dialog is opened.

PropTypeDefault valueRequired
asChildboolean-No

Examples

Center

This is the default Dialog position.

Aligned to the corners of the screen

You can ask the Dialog to appear from one of the four corners of the screen using the position property that must be applied to the DialogContent subcomponent. Possible values ​​are: top, right, bottom and left.

Scrollable content

The Dialog that comes from the sides will automatically enable scrolling if the content exceeds the height of the device. Note that Dialog with position value center, top or bottom is not intended to have long extensions of content and therefore does not have scroll by default.

Closing programmatically

Use props to close the Dialog programmatically. For example, after completing an asynchronous action.