--- title: 自定义浮层示例 description: 使用 UI 组件构建有返回值的 modal、sheet 和 drawer。 order: 30 toc: - id: typed-modal title: 类型化 Modal - id: sheet title: Sheet - id: drawer title: Drawer --- ## 类型化 Modal {#typed-modal} render callback 接收 `close` 和 `dismiss`。`close` 返回业务结果,`dismiss` 进入取消路径。 ```tsx import { openModal } from "@workspace/overlays/modal" import { Button } from "@workspace/ui/components/button" function PlanButton() { async function choosePlan() { const plan = await openModal<"free" | "pro">({ title: "选择方案", description: "以后仍然可以修改。", content: ({ close, dismiss }) => (