DocsBlog
  • 0.25.3

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Styling
Theming

Concepts

OverviewCompositionTesting

Layout

Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

Prompt Modal

The Prompt Modal is used to prompt the user for input, such as a passkey or confirmation for destructive actions.

  • npm
  • source
  • recipe
  • Ark
import { PromptModal, usePromptModal } from '@cerberus/react'

Usage

Non-destructive

Copy
some-page.tsx
import { PromptModal, usePromptModal } from '@cerberus/react'
function SomeFeature() {
const prompt = usePromptModal()
const [userValue, setUserValue] = useState<string | null>(null)
const handleClick = useCallback(async () => {
const key = 'SUPER_SECRET'
const userPrompt = await prompt.show({
heading: 'Enter passkey',
description:
'In order to view the super secret stuff you need to enter your passkey.',
key,
actionText: 'Copy passkey',
cancelText: NOPE,
})
if (userPrompt === key) setUserValue('Super secret stuff')
}, [prompt])
return (
<Button onClick={handleClick}>View passkey</Button>
)
}
function SomePage() {
return(
<PromptModal>
<SomeFeature />
</PromptModal>
)
}

Destructive

Copy
some-page.tsx
import { PromptModal, usePromptModal } from '@cerberus/react'
function SomeFeature() {
const prompt = usePromptModal()
const [userValue, setUserValue] = useState<string | null>(null)
const handleClick = useCallback(async () => {
const key = 'DELETE'
const userConsent = await prompt.show({
kind: 'destructive',
heading: 'Remove payment method?',
description: 'This is a permanent action and cannot be undone.',
key,
actionText: 'Yes, delete',
cancelText: NOPE,
})
if (userConsent === key) setUserValue('Payment method removed')
}, [prompt])
return (
<Button palette="danger" onClick={handleClick}>Delete card</Button>
)
}
function SomePage() {
return(
<PromptModal>
<SomeFeature />
</PromptModal>
)
}

Primitives

The PromptModal is an abstraction of the Dialog primitives and does not provide any additional customization. To build your own PromptModal, use the Dialog components.

API

export interface PromptModalProviderValue {
show: (options: PromptModalOptions) => Promise<string>
}
define function PromptModal(props: PropsWithChildren<DialogRootProps>): ReactNode

PromptModal

The PromptModal component is an abstraction of the Dialog and accepts the same props as the Dialog component.

Show Method Options

The show method accepts the following options:

NameDefaultDescription
kindnon-destructiveThe variant used to theme the modal.
headingThe heading of the modal.
descriptionThe description of the modal.
keyA string key to test the user input against.
actionTextThe text for the action button.
cancelTextThe text for the cancel button.

On this page

  • Edit this page on Github
Cerberus Design System | Docs