Made with create-react-library
yarn add material-ui-dialog-alert
npm install --save material-ui-dialog-alert
import React from 'react';
import { DialogAlertRoot, DialogAlert } from 'material-ui-dialog-alert';
const Child = () => {
const clickHandler = () => {
DialogAlert.show({
closeOnOverlayTap: false,
dialogProps: undefined, // dialogProps (optional)
title: 'My title', // string (optional),
description: 'my description', // string or JSX.Element (optional),
buttons: [
{
title: 'Cancel',
buttonProps: { color: 'secondary' },
onClick: () => {
console.log('callback button Cancel');
DialogAlert.hide();
},
},
{
title: 'Ok',
buttonProps: { color: 'primary' },
onClick: () => {
alert('callback button Ok');
DialogAlert.hide();
},
},
],
onClose: () => console.log('dialog alert is close'), // (optional)
});
};
return <button onClick={clickHandler}>Test My</button>;
};
const Parent = () => {
return (
<DialogAlertRoot dialogProps={{ maxWidth: 'xs' }} closeOnOverlayTap={false}>
<Child />
</DialogAlertRoot>
);
};
export default Parent;
A React node that will be most likely wrapping your whole app.
Name | Description | Require | Default | Type |
---|---|---|---|---|
dialogProps | Partial<DialogProps> | |||
closeOnOverlayTap | allow close if click in overlay | false | bool |
Name | Description | Require | Default | Type |
---|---|---|---|---|
title | The title text | false | String | |
description | The description text or JEX.Element | false | String | |
buttons | buttons | true | [IButton] OR [IButton, IButton] | |
closeOnOverlayTap | allow close if click in overlay | false | bool | |
dialogProps | Partial<DialogProps> |
type IButton = { buttonProps?: ButtonProps; title: string; onClick: () => void };
export type IConfig = {
closeOnOverlayTap?: boolean;
dialogProps?: Partial<DialogProps>;
title: string;
description: string | ReactElement;
buttons: [IButton] | [IButton, IButton];
};
MIT © CodingByJerez Rodolphe Jerez