Drawer (抽屉)
从任意边缘滑出的抽屉面板,支持尺寸与标题。
基础用法
Basic.vue
方向
Placement.vue
尺寸
Sizes.vue
带标题
Title.vue
不可关闭
NonDismissable.vue
手机端下滑关闭
底部抽屉可以往下拖着关掉
贴着底边的抽屉(包括 responsive 在 md 以下自动变成的底部 sheet)在触屏上可以往下拖关闭,拖过高度的 25% 或快速一甩即可,不够则回弹,遮罩的暗度跟着手指走。内容还没滚回顶部时,下滑仍然是滚动。左/右/上方向的抽屉、桌面端和鼠标都不受影响;isDismissable=false 拖不动,也可用 isSwipeDismissable=false 单独关掉。
Android 返回键
返回键关闭抽屉,而不是退回上一页
在 Android 上打开抽屉时,按返回键或使用返回手势会关掉最上层的抽屉,页面留在原地。桌面端与 iOS 不受影响。isDismissable=false 时不生效,也可用 isCloseRequestDismissable=false 单独关掉。KunUI 不会向 history 里写任何东西,不会干扰你的路由。
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| modelValue * | boolean | — | |
| ariaLabel | string | "" | Accessible name for a drawer with no visible title. Ignored when `title` is set. With neither, KunUI warns in dev. |
| className | string | "" | |
| innerClassName | string | "" | |
| isCloseRequestDismissable | boolean | true | Whether a platform close request dismisses the drawer — in practice Android's back button and back gesture, which close the drawer instead of leaving the page. Desktop is unaffected: its only close request is Escape, handled separately. Ignored when `isDismissable` is `false`. |
| isDismissable | boolean | true | |
| isShowCloseButton | boolean | true | |
| isSwipeDismissable | boolean | true | Whether dragging the drawer downwards dismisses it, and whether the drag handle that advertises the gesture is drawn. Only applies to a drawer sitting on the bottom edge — including a `responsive` one that becomes a bottom sheet below `md` — on a touch-primary pointer, and only while the content is scrolled to the top. Ignored when `isDismissable` is `false`. |
| placement | KunDrawerPlacement | "right" | |
| responsive | boolean | true | |
| rounded | KunUIRounded | — | |
| size | KunDrawerSize | "md" | |
| title | string | "" | Rendered in the header and wired to `aria-labelledby`. Prefer it over `ariaLabel`. |
| withContainer | boolean | true |
事件
| 事件 | 回调参数 |
|---|---|
| close | — |
| update:modelValue | value: boolean |
插槽
| 插槽 | 作用域 |
|---|---|
| #default | — |
| #footer | — |
| #header | — |