Docs
Components
Dialog

Dialog

A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.

Anatomy

Import all parts and create your own Dialog.

import { Dialog } from '@micode-ui/react';
 
<Dialog.Root>
  <Dialog.Trigger />
  <Dialog.Content>
    <Dialog.Title />
    <Dialog.Description />
  </Dialog.Content>
</Dialog.Root>

Example

<Surface>
  <Dialog.Root>
    <Dialog.Trigger>
      <Button>Open Dialog</Button>
    </Dialog.Trigger>
    <Dialog.Content>
      <Dialog.Title>Lorem Ipsum dolor</Dialog.Title>
      <Dialog.Description>
        Lorem ipsum dolor sit amet scelerisque in dictum non consectetur a
        erat nam at lectus urna duis convallis convallis tellus
      </Dialog.Description>
    </Dialog.Content>
  </Dialog.Root>
</Surface>

API Reference

Root

Contains all the parts of a dialog.

Prop

Type

Default

defaultOpenbooleanNo default value
openbooleanNo default value
onOpenChangefunctionNo default value
modalbooleantrue
idstringNo default value

Trigger

The button that opens the dialog.

Prop

Type

Default

childrenReactNodeNo default value

Content

Contains content to be rendered in the open dialog.

Prop

Type

Default

asChildbooleanfalse
forceMountbooleanNo default value
onOpenAutoFocusfunctionNo default value
onCloseAutoFocusfunctionNo default value
onEscapeKeyDownfunctionNo default value
onPointerDownOutsidefunctionNo default value
onInteractOutsidefunctionNo default value

Title

An accessible title to be announced when the dialog is opened.

If you want to hide the title, wrap it inside our Visually Hidden utility like this <VisuallyHidden asChild>.

Prop

Type

Default

asChildbooleanfalse

Description

An optional accessible description to be announced when the dialog is opened.

If you want to hide the description, wrap it inside our Visually Hidden utility like this <VisuallyHidden asChild>. If you want to remove the description entirely, remove this part and pass aria-describedby={undefined} to Dialog.Content.

Prop

Type

Default

asChildbooleanfalse