Components
Dialog

Dialog

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

Usage

import { 
  Dialog,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogBody,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
  DialogClose,
  } from from "@momo-webplatform/mobase";
<Dialog>
  <DialogTrigger asChild>
    <Button variant="primary">Sửa thông tin user</Button>
  </DialogTrigger>
  <DialogContent size="md">
    <DialogHeader >
      <DialogTitle>Sửa thông tin user</DialogTitle>
    </DialogHeader>
    <DialogBody>
      <div className="grid grid-col-1 md:grid-col-2 gap-x-4 gap-y-6">
        <div>
          <TextInput
            label="First Name"
            placeholder="Please enter first name"
            className="w-full"
          />
        </div>
        <div>
          <TextInput
            label="Last Name"
            placeholder="Please enter last name"
            className="w-full"
          />
        </div>
        <div className="md:col-span-2">
          <TextInput
            label="Email"
            type="email"
            placeholder="Please enter email"
            className="w-full"
          />
        </div>
        <div className="md:col-span-2">
          <TextArea
            label="About"
            placeholder="Please enter about"
            className="w-full"
          />
        </div>
      </div>
    </DialogBody>
    <DialogFooter>
      <DialogClose className="px-4 h-10 rounded-md hover:bg-gray-100 text-sm">Quay lại</DialogClose>
      <Button type="submit">Xác nhận</Button>
    </DialogFooter>
  </DialogContent>
</Dialog>

Examples

Size

Each size has a static width and a maximum height. Dialog can shrink to fit its body contents, but should not grow in height beyond the values provided. Dialogs with a lot of content will have a vertically scrollable body section.

Select a size

Position

By default, Dialog is positioned in the center of a screen. Center, full screen, and bottom sheets are suitable for most Dialogs. Left and right aligned Dialogs are typically reserved for global navigation.

Select a position

Is full screen

NOTE: Prop isFull only applies full screen on mobile screens. For desktops, Dialog will display the size according to the value of prop size and prop height.
With position bottom, width dialog will always full screen on mobile.
With position left and right, height dialog will always full screen on mobile and desktop.

Height

By default, Dialog height is auto. You can set height to small, large, or full screen.

Select a position
Select height

Is full screen

API Reference

Dialog component extends Radix Dialog (opens in a new tab) component and supports all of its props.

Dialog
PropTypeDefaultRequired
open
enumboolean--false
defaultOpen
enumboolean--false
onOpenChange
(open: boolean) => void--false
modal
enumboolean--false
DialogPortal
PropTypeDefaultRequired
container
HTMLElement--false
forceMount
true--false
DialogOverlay
PropTypeDefaultRequired
forceMount
true--false
asChild
enumboolean--false
DialogClose
PropTypeDefaultRequired
asChild
enumboolean--false
DialogTrigger
PropTypeDefaultRequired
asChild
enumboolean--false
DialogContent
PropTypeDefaultRequired
forceMount
true--false
asChild
enumboolean--false
onEscapeKeyDown
(event: KeyboardEvent) => void--false
onPointerDownOutside
(event: PointerDownOutsideEvent) => void--false
onFocusOutside
(event: FocusOutsideEvent) => void--false
onInteractOutside
(event: PointerDownOutsideEvent | FocusOutsideEvent) => void--false
onOpenAutoFocus
(event: Event) => void--false
onCloseAutoFocus
(event: Event) => void--false
positionRightCloseBtn
enumboolean--false
size
enumsm | md | lg | xl md false
position
enumcenter | left | right | bottom center false
hideCloseBtn
enumboolean false false
height
enumsmall | auto | large | full auto false
isFull
enumboolean false false
DialogHeader
PropTypeDefaultRequired
DialogBody
PropTypeDefaultRequired
isCondensed
enumboolean false false
DialogFooter
PropTypeDefaultRequired
isDivider
enumboolean true false
DialogTitle
PropTypeDefaultRequired
asChild
enumboolean--false
DialogDescription
PropTypeDefaultRequired
asChild
enumboolean--false