Concepts
OverviewCompositionTestingLayout
Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrapComponents
AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltipUtilities
Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsThemeThe Confirm Modal component provides a way to confirm actions with users, ensuring they are aware of the consequences before proceeding.
import { ConfirmModal, useConfirmModal } from '@cerberus/react'import { ConfirmModal, useConfirmModal } from '@cerberus/react'
function SomeFeature() { const confirm = useConfirmModal()
const handleClick = useCallback(async () => { const userConsent = await confirm.show({ heading: 'Add new payment method?', description: ( <> This will add a new payment method to your account to be billed for future purchases.{' '} <a className={css({ textStyle: 'link', })} href="#" > Learn more </a> . </> ), actionText: 'Yes, add payment method', cancelText: NOPE, }) setConsent(userConsent) }, [confirm])
return ( <Button onClick={handleConfirm}>Confirm</Button> )}function SomePage() { return( <ConfirmModal> <SomeFeature /> </ConfirmModal> )}import { ConfirmModal, useConfirmModal } from '@cerberus/react'
function SomeFeature() { const confirm = useConfirmModal()
const handleConfirm = useCallback(async () => { const consent = await confirm.show({ kind: 'destructive', heading: 'Remove payment method?', description: 'This is a permanent action and cannot be undone.', actionText: 'Yes, delete', cancelText: 'No, cancel', }) // do something with consent }, [])
return ( <Button palette="danger" onClick={handleConfirm}>Delete card</Button> )}
function SomePage() { return( <ConfirmModal> <SomeFeature /> </ConfirmModal> )}import { ConfirmModal, useConfirmModal } from '@cerberus/react'
function SomeFeature() { const confirm = useConfirmModal()
const handleClick = useCallback(async () => { const userConsent = await confirm.show({ heading: 'Add new payment method?', description: ( <> This will add a new payment method to your account to be billed for future purchases.{' '} <a className={css({ textStyle: 'link', })} href="#" > Learn more </a> . </> ), actionText: 'Yes, add payment method', cancelText: NOPE, showAvatar: false, }) setConsent(userConsent) }, [confirm])
return ( <Button onClick={handleConfirm}>Confirm</Button> )}function SomePage() { return( <ConfirmModal> <SomeFeature /> </ConfirmModal> )}The ConfirmModal is an abstraction of the Dialog primitives and does not provide any additional customization. To build your own ConfirmModal, use the Dialog components.
export type ShowConfirmModalOptions = | NonDestructiveConfirmModalOptions | DestructiveConfirmOptions
export interface ConfirmModalProviderValue { show: (options: ShowConfirmModalOptions) => Promise<boolean>}
define function ConfirmModal(props: PropsWithChildren<DialogRootProps>): ReactNodeThe ConfirmModal component is an abstraction of the Dialog and accepts the same
props as the Dialog component.
The show method accepts the following options:
| Name | Default | Description |
|---|---|---|
| kind | non-destructive | The variant used to theme the modal. |
| heading | The heading of the modal. | |
| description | The description of the modal. For non-destructive modals only, can be a ReactNode. | |
| actionText | The text for the action button. | |
| cancelText | The text for the cancel button. |
On this page