Drawer
支持四边缘滑出、经典模态栏位、长内容滚动与多档位吸附的 Duostrap 抽屉面板。
Duostrap Drawer 复用经典 6px 圆角模态框视觉语法(页眉分割线、灰底右对齐页脚与渐变按钮),支持从视口上、下、左、右四个边缘滑出、内部滚动以及拖拽吸附档位。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-drawer-root a11y-label="Workspace preferences">
<wc-duostrap-drawer-trigger>
Open Drawer
</wc-duostrap-drawer-trigger>
<wc-duostrap-drawer-mask></wc-duostrap-drawer-mask>
<wc-duostrap-drawer-content side="bottom">
<wc-duostrap-drawer-handle></wc-duostrap-drawer-handle>
<wc-duostrap-drawer-header>
<wc-duostrap-drawer-title>
Workspace Preferences
</wc-duostrap-drawer-title>
<wc-duostrap-drawer-description>
Review default notification and digest rules for this
project.
</wc-duostrap-drawer-description>
</wc-duostrap-drawer-header>
<div class="p-[15px]">Daily digest: Enabled at 09:00 UTC</div>
<wc-duostrap-drawer-footer>
<wc-duostrap-drawer-close>Close</wc-duostrap-drawer-close>
</wc-duostrap-drawer-footer>
</wc-duostrap-drawer-content>
</wc-duostrap-drawer-root>将于 0.3.0-rc.1 及后续版本中提供(@proto.ui/prototypes-duostrap/drawer)。
import { BootstrapDrawerRoot, BootstrapDrawerTrigger, BootstrapDrawerMask, BootstrapDrawerContent, BootstrapDrawerHandle, BootstrapDrawerHeader, BootstrapDrawerTitle, BootstrapDrawerDescription, BootstrapDrawerFooter, BootstrapDrawerClose,} from '../proto-ui/components/react';<BootstrapDrawerRoot> <BootstrapDrawerTrigger>Open Drawer</BootstrapDrawerTrigger> <BootstrapDrawerMask /> <BootstrapDrawerContent side="bottom"> <BootstrapDrawerHandle /> <BootstrapDrawerHeader> <BootstrapDrawerTitle>Workspace Preferences</BootstrapDrawerTitle> <BootstrapDrawerDescription> Review default notification and digest rules for this project. </BootstrapDrawerDescription> </BootstrapDrawerHeader> <div className="p-[15px]">{/* Body content */}</div> <BootstrapDrawerFooter> <BootstrapDrawerClose>Close</BootstrapDrawerClose> </BootstrapDrawerFooter> </BootstrapDrawerContent></BootstrapDrawerRoot>DrawerRoot├── DrawerTrigger├── DrawerMask└── DrawerContent ├── DrawerHandle ├── DrawerHeader │ ├── DrawerTitle │ └── DrawerDescription └── DrawerFooter └── DrawerClose- 尺寸与滚动:上下方向的
Content默认按内容高度展示并受视口安全区域约束;左右方向默认宽度上限为20个root-text单位。将长正文放入flex-1 overflow-y-auto容器,可保持经典Header与Footer固定在上下两端。 - 自定义范围与吸附:在
Content上配置minExtent/maxExtent(单位支持'logical'、'root-text'、'available'、'available-minus-root-text')以及(0, 1]比例数组snapPoints,Handle会自动在显式吸附模式下提供separator语义与方向键、Home/End调节。 - 关闭与动效:
Content内置 300ms 滑入过渡,Mask内置 150ms 淡入淡出,并自动响应系统的减少动态效果偏好。
四个弹出方向
Section titled “四个弹出方向” Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-drawer-root a11y-label="Right Drawer">
<wc-duostrap-drawer-trigger>Right</wc-duostrap-drawer-trigger>
<wc-duostrap-drawer-mask></wc-duostrap-drawer-mask>
<wc-duostrap-drawer-content side="right">
<wc-duostrap-drawer-handle></wc-duostrap-drawer-handle>
<wc-duostrap-drawer-header>
<wc-duostrap-drawer-title>
Right Drawer
</wc-duostrap-drawer-title>
<wc-duostrap-drawer-description>
Slides in from the right edge.
</wc-duostrap-drawer-description>
</wc-duostrap-drawer-header>
<wc-duostrap-drawer-footer>
<wc-duostrap-drawer-close>Close</wc-duostrap-drawer-close>
</wc-duostrap-drawer-footer>
</wc-duostrap-drawer-content>
</wc-duostrap-drawer-root> Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-drawer-root a11y-label="System activity log">
<wc-duostrap-drawer-trigger>
Scrollable Content
</wc-duostrap-drawer-trigger>
<wc-duostrap-drawer-mask></wc-duostrap-drawer-mask>
<wc-duostrap-drawer-content side="bottom">
<wc-duostrap-drawer-handle></wc-duostrap-drawer-handle>
<wc-duostrap-drawer-header>
<wc-duostrap-drawer-title>
System Activity Log
</wc-duostrap-drawer-title>
</wc-duostrap-drawer-header>
<div class="flex-1 overflow-y-auto p-[15px] space-y-2">
<!-- Scrollable log entries -->
</div>
<wc-duostrap-drawer-footer>
<wc-duostrap-drawer-close>Close</wc-duostrap-drawer-close>
</wc-duostrap-drawer-footer>
</wc-duostrap-drawer-content>
</wc-duostrap-drawer-root>显式吸附档位(Snap Points)
Section titled “显式吸附档位(Snap Points)” Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-drawer-root a11y-label="Snap points drawer">
<wc-duostrap-drawer-trigger>
Open Snap Drawer
</wc-duostrap-drawer-trigger>
<wc-duostrap-drawer-mask></wc-duostrap-drawer-mask>
<wc-duostrap-drawer-content
id="bootstrap-snap-content"
side="bottom"
>
<wc-duostrap-drawer-handle
a11y-label="Resize drawer height"
></wc-duostrap-drawer-handle>
<wc-duostrap-drawer-header>
<wc-duostrap-drawer-title>
Snap Points
</wc-duostrap-drawer-title>
</wc-duostrap-drawer-header>
<wc-duostrap-drawer-footer>
<wc-duostrap-drawer-close>Close</wc-duostrap-drawer-close>
</wc-duostrap-drawer-footer>
</wc-duostrap-drawer-content>
</wc-duostrap-drawer-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(
document.querySelector('#bootstrap-snap-content'),
{
side: 'bottom',
snapPoints: [0.5, 1],
defaultSnapPoint: 0.5,
}
);
</script>自定义尺寸与禁用拖拽关闭
Section titled “自定义尺寸与禁用拖拽关闭” Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-drawer-root a11y-label="Custom sized drawer">
<wc-duostrap-drawer-trigger>
Custom Size & Locked Drag
</wc-duostrap-drawer-trigger>
<wc-duostrap-drawer-mask></wc-duostrap-drawer-mask>
<wc-duostrap-drawer-content
id="bootstrap-sized-content"
side="right"
>
<wc-duostrap-drawer-header>
<wc-duostrap-drawer-title>
Inspector Panel
</wc-duostrap-drawer-title>
</wc-duostrap-drawer-header>
<wc-duostrap-drawer-footer>
<wc-duostrap-drawer-close>Close</wc-duostrap-drawer-close>
</wc-duostrap-drawer-footer>
</wc-duostrap-drawer-content>
</wc-duostrap-drawer-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(
document.querySelector('#bootstrap-sized-content'),
{
side: 'right',
maxExtent: { unit: 'logical', value: 420 },
dragDismissible: false,
}
);
</script>传入 open 进入受控模式,通过 openChange 监听状态变更请求;同时暴露 openDrawer()、close() 与 toggle() 方法。
| 属性 | 类型 | 默认值 |
|---|---|---|
open | boolean | — |
defaultOpen | boolean | false |
disabled | boolean | false |
a11yLabel | string | '' |
Content
Section titled “Content”暴露 open、snapPoint、dragging、dragProgress、offsetPercentage、extentValid、requestSnapPoint() 及 snapPointChange 事件。
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
side | 'top' 'right' 'bottom' 'left' | 'bottom' | — |
snapPoints | number[] | — | — |
snapPoint | number | — | — |
defaultSnapPoint | number | — | — |
minExtent | AvailableLayoutLength | { unit: 'logical', value: 0 } | — |
maxExtent | AvailableLayoutLength | 按方向默认 | 上下 { unit: 'available', value: 1 } / 左右 { unit: 'root-text', value: 20 } |
dragDismissible | boolean | true | — |
dragDismissThreshold | number | 0.25 | — |
enterDuration | number | 300 | — |
leaveDuration | number | 300 | — |
Mask / Handle / Trigger / Close
Section titled “Mask / Handle / Trigger / Close”| 属性 | 类型 | 默认值 |
|---|---|---|
Mask.passthrough | boolean | false |
Mask.enterDuration / leaveDuration | number | 150 |
Handle.disabled | boolean | false |
Handle.a11yLabel | string | 'Resize drawer' |
Trigger / Close.disabled | boolean | false |
Header、Footer、Title 与 Description 不声明额外属性。