UNPKG

4.04 kBTypeScriptView Raw
1import * as React from 'react';
2import { SxProps, Breakpoint } from '@mui/system';
3import { InternalStandardProps as StandardProps, Theme } from '..';
4import { PaperProps } from '../Paper';
5import { ModalProps } from '../Modal';
6import { TransitionProps } from '../transitions/transition';
7import { DialogClasses } from './dialogClasses';
8
9export interface DialogProps extends StandardProps<ModalProps, 'children'> {
10 /**
11 * The id(s) of the element(s) that describe the dialog.
12 */
13 'aria-describedby'?: string;
14 /**
15 * The id(s) of the element(s) that label the dialog.
16 */
17 'aria-labelledby'?: string;
18 /**
19 * Informs assistive technologies that the element is modal.
20 * It's added on the element with role="dialog".
21 * @default true
22 */
23 'aria-modal'?: boolean | 'true' | 'false';
24 /**
25 * Dialog children, usually the included sub-components.
26 */
27 children?: React.ReactNode;
28 /**
29 * Override or extend the styles applied to the component.
30 */
31 classes?: Partial<DialogClasses>;
32 /**
33 * If `true`, hitting escape will not fire the `onClose` callback.
34 * @default false
35 */
36 disableEscapeKeyDown?: boolean;
37 /**
38 * If `true`, the dialog is full-screen.
39 * @default false
40 */
41 fullScreen?: boolean;
42 /**
43 * If `true`, the dialog stretches to `maxWidth`.
44 *
45 * Notice that the dialog width grow is limited by the default margin.
46 * @default false
47 */
48 fullWidth?: boolean;
49 /**
50 * Determine the max-width of the dialog.
51 * The dialog width grows with the size of the screen.
52 * Set to `false` to disable `maxWidth`.
53 * @default 'sm'
54 */
55 maxWidth?: Breakpoint | false;
56 /**
57 * Callback fired when the backdrop is clicked.
58 * @deprecated Use the `onClose` prop with the `reason` argument to handle the `backdropClick` events.
59 */
60 onBackdropClick?: ModalProps['onBackdropClick'];
61 /**
62 * Callback fired when the component requests to be closed.
63 *
64 * @param {object} event The event source of the callback.
65 * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
66 */
67 onClose?: ModalProps['onClose'];
68 /**
69 * If `true`, the component is shown.
70 */
71 open: ModalProps['open'];
72 /**
73 * The component used to render the body of the dialog.
74 * @default Paper
75 */
76 PaperComponent?: React.JSXElementConstructor<PaperProps>;
77 /**
78 * Props applied to the [`Paper`](https://mui.com/material-ui/api/paper/) element.
79 * @default {}
80 */
81 PaperProps?: Partial<PaperProps<React.ElementType>>;
82 /**
83 * Determine the container for scrolling the dialog.
84 * @default 'paper'
85 */
86 scroll?: 'body' | 'paper';
87 /**
88 * The system prop that allows defining system overrides as well as additional CSS styles.
89 */
90 sx?: SxProps<Theme>;
91 /**
92 * The component used for the transition.
93 * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
94 * @default Fade
95 */
96 TransitionComponent?: React.JSXElementConstructor<
97 TransitionProps & { children: React.ReactElement<unknown, any> }
98 >;
99 /**
100 * The duration for the transition, in milliseconds.
101 * You may specify a single timeout for all transitions, or individually with an object.
102 * @default {
103 * enter: theme.transitions.duration.enteringScreen,
104 * exit: theme.transitions.duration.leavingScreen,
105 * }
106 */
107 transitionDuration?: TransitionProps['timeout'];
108 /**
109 * Props applied to the transition element.
110 * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
111 */
112 TransitionProps?: TransitionProps;
113}
114
115/**
116 * Dialogs are overlaid modal paper based components with a backdrop.
117 *
118 * Demos:
119 *
120 * - [Dialog](https://mui.com/material-ui/react-dialog/)
121 *
122 * API:
123 *
124 * - [Dialog API](https://mui.com/material-ui/api/dialog/)
125 * - inherits [Modal API](https://mui.com/material-ui/api/modal/)
126 */
127export default function Dialog(props: DialogProps): React.JSX.Element;