Oddmash UI
所有组件

Alert

要求确认重要消息。

用法

使用 AlertDialog 确认消息,使用 Alert 显示行内状态。

无障碍

模态框限制焦点并在确认后恢复。行内警告可使用 role="alert"。

属性类型默认值
openbooleanRequired
titlestringRequired
onConfirm() => voidRequired
confirmLabelstringOK
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>
    </>
  );
};

交互式文档