<ConfirmDialog />
@webstencils/ui
Provides a minimal implementation of a confirmation dialog with customizable options.
Reference
Props
title
string - optional, dialog title, defaults toConfirm
content
ReactNode | string - dialog contenthideCancelButton
boolean - optional, hidesCancel
buttoncancelText
string - optional, custom text forCancel
button, defaults toCancel
submitText
string - optional, custom text forSubmit
button, defaults toOK
onCancel
() => void - optional, cancel click handleronSubmit
() => void - optional, submit click handler...props
Object - the props of the element
Example
import { useEditor } from '@webstencils/core';
import { ConfirmDialog, useDialog } from '@webstencils/ui';
function MyComponent() {
const [openDialog, closeDialog] = useDialog();
const onHandleButtonClick = () => {
openDialog({
children: (
<ConfirmDialog
title={'Demo dialog title'}
content={'The dialog content comes here.'}
hideCancelButton={true}
onCancel={closeDialog}
onSubmit={closeDialog}
/>
)
});
};
return (
<>
<button>
Show confirm dialog
</button>
</>
);
}