Alert
要求确认重要消息。
用法
使用 AlertDialog 确认消息,使用 Alert 显示行内状态。
无障碍
模态框限制焦点并在确认后恢复。行内警告可使用 role="alert"。
| 属性 | 类型 | 默认值 |
|---|---|---|
| open | boolean | Required |
| title | string | Required |
| onConfirm | () => void | Required |
| confirmLabel | string | OK |
import { useState } from 'react';
export const RecordingNotice = () => {
const [visible, setVisible] = useState(false);
return (
<>
<Button onClick={() => setVisible(true)}>Show alert</Button>
<AlertDialog open={visible} title="Recording stopped" onConfirm={() => setVisible(false)}>
Reconnect the inspector to continue capturing events.
</AlertDialog>
</>
);
};