Reference version

This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).

BasicAlertDialog

A Jetpack Compose BasicAlertDialog component for displaying dialogs with custom content.

Android

Expo UI BasicAlertDialog matches the official Jetpack Compose BasicAlertDialog API and displays a minimal dialog that accepts custom children as its content, giving you full control over the dialog layout.

Installation

Terminal
npx expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

Basic dialog with custom content

BasicAlertDialogExample.tsx
import { useState } from 'react'; import { Host, BasicAlertDialog, Button, Text, Surface, Column } from '@expo/ui/jetpack-compose'; import { paddingAll } from '@expo/ui/jetpack-compose/modifiers'; export default function BasicAlertDialogExample() { const [visible, setVisible] = useState(false); return ( <Host matchContents> <Button onPress={() => setVisible(true)}>Show Dialog</Button> {visible && ( <BasicAlertDialog onDismissRequest={() => setVisible(false)}> <Surface color="#FFFFFF" modifiers={[paddingAll(24)]}> <Column verticalArrangement={{ spacedBy: 8 }}> <Text style={{ fontSize: 18, fontWeight: 'bold' }}>Custom Dialog</Text> <Text>This dialog contains fully custom content defined as children.</Text> <Button onPress={() => setVisible(false)}>Close</Button> </Column> </Surface> </BasicAlertDialog> )} </Host> ); }

API

import { BasicAlertDialog } from '@expo/ui/jetpack-compose';

Component

BasicAlertDialog

Android

Type: React.Element<BasicAlertDialogProps>

A basic alert dialog that provides a blank container for custom content. Unlike AlertDialog, this component does not have structured title/text/buttons slots.

BasicAlertDialogProps

children

Android
Optional • Type: React.ReactNode

The content to display inside the dialog.

modifiers

Android
Optional • Type: ExpoModifier[]

Modifiers for the component.

onDismissRequest

Android
Optional • Type: () => void

Callback that is called when the user tries to dismiss the dialog (e.g. by tapping outside of it or pressing the back button).