UNPKG

2.41 kBTypeScriptView Raw
1import * as React from 'react';
2import { StandardProps } from '@material-ui/core';
3import { PaperProps } from '@material-ui/core/Paper';
4
5export type Color = 'success' | 'info' | 'warning' | 'error';
6
7export interface AlertProps extends StandardProps<PaperProps, AlertClassKey, 'variant'> {
8 /**
9 * The action to display. It renders after the message, at the end of the alert.
10 */
11 action?: React.ReactNode;
12 /**
13 * Override the default label for the *close popup* icon button.
14 *
15 * For localization purposes, you can use the provided [translations](/guides/localization/).
16 */
17 closeText?: string;
18 /**
19 * The main color for the alert. Unless provided, the value is taken from the `severity` prop.
20 */
21 color?: Color;
22 /**
23 * The severity of the alert. This defines the color and icon used.
24 */
25 severity?: Color;
26 /**
27 * Override the icon displayed before the children.
28 * Unless provided, the icon is mapped to the value of the `severity` prop.
29 */
30 icon?: React.ReactNode | false;
31 /**
32 * The ARIA role attribute of the element.
33 */
34 role?: string;
35 /**
36 * The component maps the `severity` prop to a range of different icons,
37 * for instance success to `<SuccessOutlined>`.
38 * If you wish to change this mapping, you can provide your own.
39 * Alternatively, you can use the `icon` prop to override the icon displayed.
40 */
41 iconMapping?: Partial<Record<Color, React.ReactNode>>;
42 /**
43 * Callback fired when the component requests to be closed.
44 * When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
45 *
46 * @param {object} event The event source of the callback.
47 */
48 onClose?: (event: React.SyntheticEvent) => void;
49 /**
50 * The variant to use.
51 */
52 variant?: 'standard' | 'filled' | 'outlined';
53}
54
55export type AlertClassKey =
56 | 'root'
57 | 'standardSuccess'
58 | 'standardInfo'
59 | 'standardWarning'
60 | 'standardError'
61 | 'outlinedSuccess'
62 | 'outlinedInfo'
63 | 'outlinedWarning'
64 | 'outlinedError'
65 | 'filledSuccess'
66 | 'filledInfo'
67 | 'filledWarning'
68 | 'filledError'
69 | 'icon'
70 | 'message'
71 | 'action';
72
73/**
74 *
75 * Demos:
76 *
77 * - [Alert](https://mui.com/components/alert/)
78 *
79 * API:
80 *
81 * - [Alert API](https://mui.com/api/alert/)
82 * - inherits [Paper API](https://mui.com/api/paper/)
83 */
84export default function Alert(props: AlertProps): JSX.Element;