Skip to content

Dialog

The Dialog component provides a modal dialog with customizable content and actions. It includes subcomponents for structured content like headers, titles, descriptions, and action buttons.

import {
Dialog,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
DialogAction,
DialogCancel,
} from '@space-uy/pulsar-ui';
const [visible, setVisible] = useState(false);
<Dialog visible={visible} onDismiss={() => setVisible(false)}>
<DialogHeader>
<DialogTitle>Confirm Action</DialogTitle>
<DialogDescription>
Are you sure you want to continue? This action cannot be undone.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogCancel onPress={() => setVisible(false)}>Cancel</DialogCancel>
<DialogAction onPress={handleConfirm}>Confirm</DialogAction>
</DialogFooter>
</Dialog>;
PropertyTypeRequiredDefault valueDescription
visibleboolean-Controls dialog visibility
onDismiss() => void-Function called when dialog should close
childrenReact.ReactNode-Content to display inside the dialog

Container for dialog header content.

PropertyTypeRequiredDefault valueDescription
childrenReact.ReactNode-Header content
styleStyleProp<ViewStyle>-Custom styles for the header

Title text component for the dialog.

PropertyTypeRequiredDefault valueDescription
childrenReact.ReactNode-Title text content
styleStyleProp<ViewStyle>-Custom styles for the title

Description text component for the dialog.

PropertyTypeRequiredDefault valueDescription
childrenReact.ReactNode-Description text content
styleStyleProp<ViewStyle>-Custom styles for the description

Container for dialog action buttons.

PropertyTypeRequiredDefault valueDescription
childrenReact.ReactNode-Footer content (buttons)
styleStyleProp<ViewStyle>-Custom styles for the footer

Primary action button for the dialog.

PropertyTypeRequiredDefault valueDescription
onPress() => void-Function called when pressed
childrenReact.ReactNode-Button text content
variant'flat' | 'outline''flat'Button visual variant
destructivebooleanfalseWhether this is a destructive action

Cancel button for the dialog.

PropertyTypeRequiredDefault valueDescription
onPress() => void-Function called when pressed
childrenReact.ReactNode-Button text content
<Dialog visible={showConfirm} onDismiss={() => setShowConfirm(false)}>
<DialogHeader>
<DialogTitle>Delete Item</DialogTitle>
<DialogDescription>
This will permanently delete the item. This action cannot be undone.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogCancel onPress={() => setShowConfirm(false)}>Cancel</DialogCancel>
<DialogAction
destructive={true}
onPress={() => {
handleDelete();
setShowConfirm(false);
}}
>
Delete
</DialogAction>
</DialogFooter>
</Dialog>
<Dialog visible={showInfo} onDismiss={() => setShowInfo(false)}>
<DialogHeader>
<DialogTitle>Welcome!</DialogTitle>
<DialogDescription>
Thank you for using our app. Here are some tips to get started.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogAction onPress={() => setShowInfo(false)}>Got it</DialogAction>
</DialogFooter>
</Dialog>
const [formData, setFormData] = useState({ name: '', email: '' });
<Dialog visible={showForm} onDismiss={() => setShowForm(false)}>
<DialogHeader>
<DialogTitle>Add Contact</DialogTitle>
<DialogDescription>Enter the contact information below.</DialogDescription>
</DialogHeader>
<View style={{ gap: 16, marginVertical: 16 }}>
<Input
label="Name"
value={formData.name}
onChangeText={(name) => setFormData((prev) => ({ ...prev, name }))}
placeholder="Enter full name"
/>
<Input
label="Email"
value={formData.email}
onChangeText={(email) => setFormData((prev) => ({ ...prev, email }))}
placeholder="Enter email address"
variant="email"
/>
</View>
<DialogFooter>
<DialogCancel onPress={() => setShowForm(false)}>Cancel</DialogCancel>
<DialogAction
onPress={() => {
handleAddContact(formData);
setShowForm(false);
}}
>
Add Contact
</DialogAction>
</DialogFooter>
</Dialog>;
<Dialog visible={showActions} onDismiss={() => setShowActions(false)}>
<DialogHeader>
<DialogTitle>Choose Action</DialogTitle>
<DialogDescription>
What would you like to do with this file?
</DialogDescription>
</DialogHeader>
<DialogFooter>
<View style={{ flexDirection: 'row', gap: 8, flexWrap: 'wrap' }}>
<DialogAction
variant="outline"
onPress={() => {
handleEdit();
setShowActions(false);
}}
>
Edit
</DialogAction>
<DialogAction
variant="outline"
onPress={() => {
handleShare();
setShowActions(false);
}}
>
Share
</DialogAction>
<DialogAction
destructive={true}
onPress={() => {
handleDelete();
setShowActions(false);
}}
>
Delete
</DialogAction>
</View>
</DialogFooter>
</Dialog>
<Dialog visible={showCustom} onDismiss={() => setShowCustom(false)}>
<View style={{ alignItems: 'center', padding: 16 }}>
<Icon name="CheckCircle" size={48} color={colors.success} />
<Text variant="h3" style={{ marginTop: 16, textAlign: 'center' }}>
Success!
</Text>
<Text variant="pm" style={{ marginTop: 8, textAlign: 'center' }}>
Your changes have been saved successfully.
</Text>
</View>
<DialogFooter>
<DialogAction onPress={() => setShowCustom(false)}>Continue</DialogAction>
</DialogFooter>
</Dialog>
<Dialog visible={isLoading} onDismiss={() => {}}>
<View style={{ alignItems: 'center', padding: 32 }}>
<LoadingIndicator size={32} />
<Text variant="h4" style={{ marginTop: 16 }}>
Processing...
</Text>
<Text variant="pm" style={{ marginTop: 8, textAlign: 'center' }}>
Please wait while we process your request.
</Text>
</View>
</Dialog>
  • The dialog uses React Native Modal for cross-platform compatibility
  • Smooth animations using React Native Reanimated with scale and opacity effects
  • Backdrop press automatically calls the onDismiss callback
  • Dialog content is automatically centered on screen
  • All subcomponents follow consistent theming and styling
  • Focus is trapped within the dialog when active
  • Supports both controlled visibility and automatic dismissal
  • Show animation: 300ms scale from 0.7 to 1.0 with opacity fade-in
  • Hide animation: 300ms scale to 0.7 with opacity fade-out
  • Backdrop: Smooth opacity transition for overlay background
  • Timing: All animations use consistent 300ms duration

The Dialog automatically applies theme styling:

  • Background: Uses theme background color
  • Border: Uses theme border color and roundness
  • Text: Uses theme typography and foreground colors
  • Buttons: Follow theme button styling conventions
<Dialog visible={visible} onDismiss={onDismiss}>
<DialogHeader style={{ backgroundColor: colors.primary + '10' }}>
<DialogTitle style={{ color: colors.primary }}>
Custom Styled Dialog
</DialogTitle>
</DialogHeader>
</Dialog>
  • Modal content is properly announced by screen readers
  • Focus management ensures keyboard navigation works correctly
  • All interactive elements maintain proper accessibility properties
  • High contrast support for users with visual impairments
  • Proper role and aria attributes for assistive technologies