Dialog

free

Dialog creates a focused modal step for confirmations and short tasks.

import { useState } from 'react';
import { PiArrowsLeftRight, PiEye, PiEyeSlash } from 'react-icons/pi'
import Button from '@/components/ui/button';
import Dialog from '@/components/ui/dialog';

Installation

Add this component with the NateUI CLI.

npx nateui@latest add Dialog

Examples

Basic

import { useState } from 'react';
import Button from '@/components/ui/button';
import Dialog from '@/components/ui/dialog';
import { PiLightning } from 'react-icons/pi'

Size

import { useState } from 'react';
import {
    PiBookmarkSimple,
    PiCode,

Custom Backdrop

import { useState } from 'react';
import { PiLightning } from 'react-icons/pi'
import Button from '@/components/ui/button';
import Dialog from '@/components/ui/dialog';

Internal Scroll

import { useState } from 'react';
import Button from '@/components/ui/button';
import Dialog from '@/components/ui/dialog';
import Scroll from '@/components/ui/scroll';

Custom Layout

import { useState } from 'react';
import Button from '@/components/ui/button';
import Dialog from '@/components/ui/dialog';
import Form from '@/components/ui/form';

Closable

import { useState } from 'react';
import Button from '@/components/ui/button';
import Dialog from '@/components/ui/dialog';
import { PiLightning } from 'react-icons/pi'

Lock Scroll

import { useState } from 'react';
import Button from '@/components/ui/button';
import Dialog from '@/components/ui/dialog';
import { PiLightning } from 'react-icons/pi'

API

Dialog accepts the props below plus native props for the dialog content div.

PropDescriptionTypeDefault
childrenModal content rendered inside the dialog surface.ReactNode-
classNameClass names applied to the dialog content surface.string-
closableShows the default close button in the top corner.booleantrue
heightFixed height applied to the dialog content surface.string | number-
isOpenControls whether the dialog is visible.booleanfalse
lockScrollLocks document scrolling through the overlay while the dialog is mounted.booleanfalse
onCloseCalled when the dialog asks to close through the close button, overlay, or Escape key. Update isOpen in this handler.DialogOpenChangeHandler-
onOpenCalled when the floating layer reports that the dialog opened.DialogOpenChangeHandler-
overlayClassNameClass names applied to the overlay element.string-
refRef forwarded to the dialog content element.Ref<HTMLDivElement>-
shouldCloseOnEscAllows Escape to request closing the dialog.booleantrue
shouldCloseOnOverlayClickAllows an overlay click to request closing the dialog.booleantrue
widthWidth of the dialog in pixels. Falls back to auto width when the viewport is narrower.number520
...nativeDivPropsNative props applied to the dialog content element.NativeDialogDivProps-

Types

type DialogOpenChangeHandler = (open: boolean) => void;
type NativeDialogDivProps = ComponentProps<'div'>;