BasicAlertDialog
一个用于显示自定义内容对话框的 Jetpack Compose BasicAlertDialog 组件。
Android
Bundled version:
~55.0.2
Expo UI BasicAlertDialog 与官方 Jetpack Compose BasicAlertDialog API 相匹配,并显示一个最小化的对话框,该对话框接受自定义子内容作为其内容,让你可以完全控制对话框布局。
🌐 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/uiIf 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
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.