ScrollShadow (滚动阴影)
带边缘渐隐阴影的滚动容器,仅在有更多内容时出现;横向条可选鼠标滚轮横向滚动、按住拖拽滚动,到两端自动交还页面滚动。
基础用法
Basic.vue
纵向
Vertical.vue
鼠标滚轮 + 拖拽(横向)
横向条上,鼠标用户既滚不动也不便拖动。开启 wheel 后竖直滚轮即可左右滚;draggable 允许按住拖动。 wheel(=true)到两端会「放手」交还页面滚动;本例用 wheel="contain"——滚到最前/最后把滚轮留在条上、页面不向下滚 (仅在条本身可滚时生效,绝不会卡死页面)。触摸设备保持原生滑动。
9.2空想科学
8.7月色真美
9.5雨声
8.1夏目
7.9星之卡比
9.0银河铁道
9.8紫罗兰
8.4凉宫
8.8秒速五厘米
9.1言叶之庭
9.6你的名字
8.5天气之子
Interactive.vue
滚动条样式由 scrollbar 控制:hide(默认,仅靠边缘阴影)、 thin(本例所用,细的、跟随主题色的滚动条,纯 CSS 零依赖)、auto(平台原生)。
建议为可滚动区域设置 aria-label,以便屏幕阅读器识别该区域。
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| ariaLabel | string | "scrollable content" | |
| axis | "horizontal" | "vertical" | "horizontal" | |
| className | string | "" | |
| contentClass | string | "" | |
| draggable | boolean | false | Click-and-drag with a mouse/pen to scroll the area, like grabbing a strip. A drag past a small threshold suppresses the click so cards inside still work on a normal click; touch is left to native scrolling. Default false. |
| scrollbar | "auto" | "hide" | "thin" | "hide" | Scrollbar style. `hide` (default) hides it — the edge shadows are the affordance; `thin` shows a slim, theme-coloured scrollbar (a dependency-free alternative to an overlay-scrollbar library); `auto` shows the platform default. |
| shadowColor | string | "var(--color-background)" | |
| shadowSize | string | "2rem" | |
| wheel | boolean | "contain" | false | When `axis='horizontal'`, let a vertical mouse wheel scroll the content sideways (mouse users otherwise can't reach off-screen content; trackpads and touch already can). `true` releases at either edge so the page scrolls on past (no scroll-trap); `'contain'` keeps the wheel on the strip at the edges so the page doesn't move — but only while the strip is actually scrollable, so it can never freeze the page. Default false. |