Skip to content
Panels and menusInteractive playground

Dialog

A focused conversation over your interface.

Preparing the playground…
Text and Markdown example
Dialog · Example
1<Dialog><DialogTrigger asChild><Button>Open dialog</Button></DialogTrigger><DialogContent><DialogHeader><DialogTitle>A space for your idea</DialogTitle><DialogDescription>Review the details before continuing.</DialogDescription></DialogHeader><div style={{padding:"24px 0"}}><Input aria-label="Project name" placeholder="Project name" /></div><DialogFooter><DialogClose asChild><Button>Done</Button></DialogClose></DialogFooter></DialogContent></Dialog>
Read documentation in Markdown

How to use it

Always include Title and Description. The trigger opens the panel, Escape closes it and focus returns to the original control. You can manage open and onOpenChange.

Import

React / Next.js
1import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose, DialogOverlay, DialogPortal } from "@kivora/nextjs";

Interactive examples run inside a component with "use client". The playground's Copy button includes the imports needed for the current example.

API reference 0.2.0

Types from the installed published version, including component properties and common HTML attributes. “Optional” does not imply a default value; omitting a property lets the component decide.

PropertyTypeDescription
childrenReactNodeContent or child elements of the component.
defaultOpenbooleanWhether it starts open in uncontrolled mode.
modalbooleanConfigures modal. The type describes the supported values and structure.
onOpenChange((open: boolean) => void)Receives the new open state.
openbooleanControlled open state.

Subcomponents and composition

Review each component's properties and published declaration. Native and accessibility attributes are inherited from the element specified by its type.

Dialog5 properties
Dialog · TypeScript
1declare function Dialog({ open, defaultOpen, onOpenChange, ...props }: DialogProps): React.JSX.Element;
DialogTrigger18 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
namestringName used to identify the control in forms.
onChangeChangeEventHandler<HTMLButtonElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLButtonElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLButtonElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
type"button" | "submit" | "reset"Operation type or mode; values depend on the component.
valuestring | number | readonly string[]Controlled value. Update it from the change callback.
DialogTrigger · TypeScript
1DialogTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>
DialogContent23 properties
PropertyTypeDescription
animation"scale" | "slide-up" | "slide-down" | "fade"Configures animation. The type describes the supported values and structure.
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
deferPointerDownOutsidebooleanWhen `true`, a `'pointerdown'` event outside of the layered element will wait for the interaction's click event before dispatching, allowing third-party code to stop propagation of later events and cancel dismissal.
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onCloseAutoFocus((event: Event) => void)Event handler called when auto-focusing on close. Can be prevented.
onEscapeKeyDown((event: KeyboardEvent) => void)Event handler called when the escape key is down. Can be prevented.
onFocusOutside((event: FocusOutsideEvent) => void)Event handler called when the focus moves outside of the `DismissableLayer`. Can be prevented.
onInteractOutside((event: PointerDownOutsideEvent | FocusOutsideEvent) => void)Event handler called when an interaction happens outside the `DismissableLayer`. Specifically, when a `pointerdown` event happens outside or focus moves outside of it. Can be prevented.
onOpenAutoFocus((event: Event) => void)Event handler called when auto-focusing on open. Can be prevented.
onPointerDownOutside((event: PointerDownOutsideEvent) => void)Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`. Can be prevented.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
DialogContent · TypeScript
1DialogContent: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>
DialogHeader13 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
DialogHeader · TypeScript
1DialogHeader: { 2 ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element; 3 displayName: string; 4}
DialogTitle14 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLHeadingElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLHeadingElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLHeadingElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
DialogTitle · TypeScript
1DialogTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>
DialogDescription14 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLParagraphElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLParagraphElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLParagraphElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
DialogDescription · TypeScript
1DialogDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>
DialogFooter13 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
DialogFooter · TypeScript
1DialogFooter: { 2 ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element; 3 displayName: string; 4}
DialogClose18 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
disabledbooleanDisable interaction with the control.
idstringElement identifier; associates labels and descriptions.
namestringName used to identify the control in forms.
onChangeChangeEventHandler<HTMLButtonElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLButtonElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLButtonElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
type"button" | "submit" | "reset"Operation type or mode; values depend on the component.
valuestring | number | readonly string[]Controlled value. Update it from the change callback.
DialogClose · TypeScript
1DialogClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>
DialogOverlay15 properties
PropertyTypeDescription
aria-labelstringAccessible name of the control.
asChildbooleanApply props and behavior to a single compatible child element.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
idstringElement identifier; associates labels and descriptions.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.
DialogOverlay · TypeScript
1DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>
DialogPortal3 properties
PropertyTypeDescription
childrenReactNodeContent or child elements of the component.
containerElement | DocumentFragment | nullSpecify a container element to portal the content into.
forceMounttrueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
DialogPortal · TypeScript
1DialogPortal: React.FC<DialogPrimitive.DialogPortalProps>
API generated from @kivora/nextjs 0.2.0View package