For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/zh/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/zh/llms-full.txt, and this page is available as Markdown at https://rickyshin93.github.io/tao-ui/zh/components/modal.md.
v0.0.57
  • 简体中文
  • Modal

    反馈@rockshin/tao-ui

    在受保护的焦点上下文中展示需要用户处理的对话框。

    何时使用

    任务需要中断当前流程、确认重要决策或集中完成短任务时使用 Modal。

    推荐

    • 标题说明用户需要完成的任务。
    • 确认按钮文案使用具体动作。
    • 异步确认期间展示 loading。

    避免

    • 不需要中断或焦点保护的内容不要放进 Modal。

    代码演示

    API

    属性说明类型默认值
    footerFooter content. - undefined renders default OK/Cancel buttons - null renders no footer - a function receives (originNode, { OkBtn, CancelBtn }) to compose around the defaultsReactNode | ModalFooterRender-
    okButtonPropsExtra props forwarded to the default OK button.ButtonProps | undefined-
    cancelButtonPropsExtra props forwarded to the default Cancel button.ButtonProps | undefined-
    widthDialog width. Accepts a breakpoint map, e.g. width={{ xs: '100%', md: 640 }} — the largest matching breakpoint wins, falling back to the 520px default when no entry matches.string | number | Partial<Record<TaoBreakpoint, string | number>> | undefined520
    centeredVertically center the dialog. Defaults to true.boolean | undefinedtrue
    closableShow the close (×) button. Defaults to true.boolean | (AriaAttributes & { disabled?: boolean | undefined; closeIcon?: ReactNode; onClose?: (() => void) | undefined; afterClose?: (() => void) | undefined; }) | undefinedtrue
    maskClosableClose when clicking the mask/overlay. Defaults to true.boolean | undefinedtrue
    keyboardClose on Esc key. Defaults to true.boolean | undefinedtrue
    getContainerPortal destination. false renders the dialog in place.string | false | HTMLElement | (() => HTMLElement) | undefined-
    afterCloseCalled after the modal has fully closed (open transitions true → false).(() => void) | undefined-
    destroyOnHiddenUnmount children when closed. Defaults to true. Set false to keep children mounted while releasing modal interaction locks when hidden.boolean | undefinedtrue