AstroLaunch UI Dialog - React

Use our AstroLaunch UI Dialog component to inform users about a task or important information that require decisions, or involves multiple tasks.

A dialog is a type of modal window with critical information which disable all app functionality when they appear and remains on screen until confirmed/dismissed.

See below our dialog example that you can use for your AstroLaunch UI and React project.



Dialog Sizes

The Dialog component comes with 6 different sizes that you can change it using the size prop.


Dialog Custom Animation

You can modify the open/close state animation for Dialog component using the animate prop.


Dialog with Form

Use the example below to create a dialog with a sign in form.


Dialog with Image

Use the example below to create a dialog with an image inside, similar to unsplash.

nature

Web 3.0 Dialog

Use the example below to create a Web 3.0 wallet connect dialog.


Long Dialog


Message Dialog


Notification Dialog


Dialog Props

The following props are available for dialog component. These are the custom props that we've added for the dialog component and you can use all the other native props as well.

AttributeTypeDescriptionDefault
openbooleanOpen the dialogNo default value it's a required prop.
handlerfunctionControls open and close states for dialogNo default value it's a required prop.
sizeSizeChange dialog sizemd
dismissDismissChange backdrop dismiss listenersundefined
animateAnimateChange dialog animationundefined
classNamestringAdd custom className for dialog''
childrennodeAdd content for dialogNo default value it's a required prop.


For TypeScript Only

import type { DialogProps } from "@material-tailwind/react";

Dialog Header Props

The following props are available for dialog header component. These are the custom props that we've added for the dialog header component and you can use all the other native props as well.

AttributeTypeDescriptionDefault
classNamestringAdd custom className for dialog header''
childrennodeAdd content for dialog headerNo default value it's a required prop.


For TypeScript Only

import type { DialogHeaderProps } from "@material-tailwind/react";

Dialog Body Props

The following props are available for dialog body component. These are the custom props that we've added for the dialog body component and you can use all the other native props as well.

AttributeTypeDescriptionDefault
dividerbooleanAdd border top & bottom for dialog bodyfalse
classNamestringAdd custom className for dialog body''
childrennodeAdd content for dialog bodyNo default value it's a required prop.


For TypeScript Only

import type { DialogBodyProps } from "@material-tailwind/react";

The following props are available for dialog footer component. These are the custom props that we've added for the dialog footer component and you can use all the other native props as well.

AttributeTypeDescriptionDefault
classNamestringAdd custom className for dialog footer''
childrennodeAdd content for dialog footerNo default value it's a required prop.


For TypeScript Only

import type { DialogFooterProps } from "@material-tailwind/react";

Types - Size

type size = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";

Types - Dismiss

type dismissType = {
  enabled?: boolean;
  escapeKey?: boolean;
  referencePress?: boolean;
  referencePressEvent?: 'pointerdown' | 'mousedown' | 'click';
  outsidePress?: boolean | ((event: MouseEvent) => boolean);
  outsidePressEvent?: 'pointerdown' | 'mousedown' | 'click';
  ancestorScroll?: boolean;
  bubbles?: boolean | {
      escapeKey?: boolean;
      outsidePress?: boolean;
  };
};

Types - Animate

type animate = {
  mount?: object;
  unmount?: object;
};

Dialog Theme

Learn how to customize the theme and styles for dialog components, the theme object for dialog components has three main objects:

A. The defaultProps object for setting up the default value for props of dialog component.
B. The valid object for customizing the valid values for dialog component props.
C. The styles object for customizing the theme and styles of dialog component.

You can customize the theme and styles of dialog components by adding Tailwind CSS classes as key paired values for objects.



Dialog Theme Object Type

interface DialogStylesType {
  defaultProps: {
    size: string;
    dismiss: {
      enabled: boolean;
      escapeKey: boolean;
      referencePress: boolean;
      referencePressEvent: 'pointerdown' | 'mousedown' | 'click';
      outsidePress: boolean | ((event: MouseEvent) => boolean);
      outsidePressEvent: 'pointerdown' | 'mousedown' | 'click';
      ancestorScroll: boolean;
      bubbles: boolean | {
          escapeKey: boolean;
          outsidePress: boolean;
      };
    };
    animate: {
      mount: object;
      unmount: object;
    };
    className: string;
  };
  valid: {
    sizes: string[];
  };
  styles: {
    base: {
      backdrop: object;
      container: object;
    };
    sizes: {
      xs: object;
      sm: object;
      md: object;
      lg: object;
      xl: object;
      xxl: object;
    };
  };
}


For TypeScript Only

import type { DialogStylesType } from "@material-tailwind/react";

Dialog Theme Customization

const theme = {
  dialog: {
    defaultProps: {
      size: "md",
      dismiss: {},
      animate: {
        unmount: {},
        mount: {},
      },
      className: "",
    },
    valid: {
      sizes: ["xs", "sm", "md", "lg", "xl", "xxl"],
    },
    styles: {
      base: {
        backdrop: {
          display: "grid",
          placeItems: "place-items-center",
          position: "fixed",
          top: 0,
          left: 0,
          width: "w-screen",
          height: "h-screen",
          backgroundColor: "bg-black",
          backgroundOpacity: "bg-opacity-60",
          backdropFilter: "backdrop-blur-sm",
        },
        container: {
          position: "relative",
          bg: "bg-white",
          m: "m-4",
          borderRadius: "rounded-lg",
          boxShadow: "shadow-2xl",
          color: "text-blue-gray-500",
          fontSmoothing: "antialiased",
          fontFamily: "font-sans",
          fontSize: "text-base",
          fontWeight: "font-light",
          lineHeight: "leading-relaxed",
        },
      },
      sizes: {
        xs: {
          width: "w-full md:w-3/5 lg:w-2/5 2xl:w-1/4",
          minWidth: "min-w-[80%] md:min-w-[60%] lg:min-w-[40%] 2xl:min-w-[25%]",
          maxWidth: "max-w-[80%] md:max-w-[60%] lg:max-w-[40%] 2xl:max-w-[25%]",
        },
        sm: {
          width: "w-full md:w-2/3 lg:w-2/4 2xl:w-1/3",
          minWidth: "min-w-[80%] md:min-w-[66.666667%] lg:min-w-[50%] 2xl:min-w-[33.333333%]",
          maxWidth: "max-w-[80%] md:max-w-[66.666667%] lg:max-w-[50%] 2xl:max-w-[33.333333%]",
        },
        md: {
          width: "w-full md:w-3/4 lg:w-3/5 2xl:w-2/5",
          minWidth: "min-w-[90%] md:min-w-[75%] lg:min-w-[60%] 2xl:min-w-[40%]",
          maxWidth: "max-w-[90%] md:max-w-[75%] lg:max-w-[60%] 2xl:max-w-[40%]",
        },
        lg: {
          width: "w-full md:w-5/6 lg:w-3/4 2xl:w-3/5",
          minWidth: "min-w-[90%] md:min-w-[83.333333%] lg:min-w-[75%] 2xl:min-w-[60%]",
          maxWidth: "max-w-[90%] md:max-w-[83.333333%] lg:max-w-[75%] 2xl:max-w-[60%]",
        },
        xl: {
          width: "w-full md:w-5/6 2xl:w-3/4",
          minWidth: "min-w-[95%] md:min-w-[83.333333%] 2xl:min-w-[75%]",
          maxWidth: "max-w-[95%] md:max-w-[83.333333%] 2xl:max-w-[75%]",
        },
        xxl: {
          display: "flex",
          flexDirection: "flex-col",
          width: "w-screen",
          minWidth: "min-w-[100vw]",
          maxWidth: "max-w-[100vw]",
          height: "h-screen",
          minHeight: "min-h-[100vh]",
          maxHeight: "max-h-[100vh]",
          m: "m-0",
          borderRadius: "rounded-none",
        },
      },
    },
  },
};

Dialog Header Theme Object Type

interface DialogHeaderStylesType {
  defaultProps: {
    className: string;
  };
  styles: {
    base: object;
  };
}


For TypeScript Only

import type { DialogHeaderStylesType } from "@material-tailwind/react";

Dialog Header Theme Customization

const theme = {
  dialogHeader: {
    defaultProps: {
      className: "",
    },
    styles: {
      base: {
        display: "flex",
        alignItems: "items-center",
        flexShrink: "shrink-0",
        p: "p-4",
        color: "text-blue-gray-900",
        fontSmoothing: "antialiased",
        fontFamily: "font-sans",
        fontSize: "text-2xl",
        fontWeight: "font-semibold",
        lineHeight: "leading-snug",
      },
    },
  },
};

Dialog Body Theme Object Type

interface DialogBodyStylesType {
  defaultProps: {
    className: string;
    divider: boolean;
  };
  styles: {
    base: {
      initial: object;
      divider: object;
    };
  };
}


For TypeScript Only

import type { DialogBodyStylesType } from "@material-tailwind/react";

Dialog Body Theme Customization

const theme = {
  dialogBody: {
    defaultProps: {
      className: "",
      divider: false,
    },
    styles: {
      base: {
        initial: {
          position: "relative",
          p: "p-4",
          color: "text-blue-gray-500",
          fontSmoothing: "antialiased",
          fontFamily: "font-sans",
          fontSize: "text-base",
          fontWeight: "font-light",
          lineHeight: "leading-relaxed",
        },
        divider: {
          borderTop: "border-t",
          borderTopColor: "border-t-blue-gray-100",
          borderBottom: "border-b",
          borderBottomColor: "border-b-blue-gray-100",
        },
      },
    },
  },
};

interface DialogFooterStylesType {
  defaultProps: {
    className: string;
  };
  styles: {
    base: object;
  };
}


For TypeScript Only

import type { DialogFooterStylesType } from "@material-tailwind/react";

const theme = {
  dialogFooter: {
    defaultProps: {
      className: "",
    },
    styles: {
      base: {
        display: "flex",
        alignItems: "items-center",
        justifyContent: "justify-end",
        flexShrink: "shrink-0",
        flexWrap: "flex-wrap",
        p: "p-4",
        color: "text-blue-gray-500",
      },
    },
  },
};


If you want to see more examples and properties please check the official Material Tailwind Documentation.