rslabdocs

Confirm Dialog

A branded confirmation overlay, not a system alert: backdrop fades in, card pops in from the center.

ReanimatedHapticsNativeWindSource

Prerequisites

Icons for the destructive warning glyph, haptics for the confirm/cancel taps, and Reanimated for the fade/scale.


npx expo install @hugeicons/core-free-icons @hugeicons/react-native expo-haptics react-native-reanimated

Install


npx @rslab/cli add confirm-dialog

Usage

import { ConfirmDialog } from '@/components/ui/ConfirmDialog';

const [open, setOpen] = useState(false);

<ConfirmDialog
  visible={open}

  title="Log out?"

  description="You'll need to sign back in to access your projects."

  confirmLabel="Log out"

  onConfirm={() => {
    logOut();

    setOpen(false);
  }}

  onCancel={() => setOpen(false)}
/>;

destructive swaps in a warning icon, a red confirm button, and a heads-up haptic the instant the dialog appears:

<ConfirmDialog
  visible={deleteOpen}

  title="Delete this project?"

  description="This can't be undone. All screens, assets, and history will be permanently removed."

  confirmLabel="Delete"

  destructive

  onConfirm={() => {
    deleteProject();

    setDeleteOpen(false);
  }}

  onCancel={() => setDeleteOpen(false)}
/>

Props

PropTypeDefault
visible
boolean
-

Controls mount/show. The exit animation still plays when it flips back to false.

title
string
-

Required headline.

description?
string
-

Optional supporting copy.

confirmLabel?
string
'Confirm'
cancelLabel?
string
'Cancel'
destructive?
boolean
false

Red confirm button, warning icon above the title, and fires a warning haptic on open.

onConfirm
() => void
-

The component never closes itself; flip visible from here.

onCancel
() => void
-

Fires on cancel, or on tapping the backdrop.

See exactly how this works with an RSLAB subscription.

Get Pro

On this page