ScrollShadow (滚动阴影)

带边缘渐隐阴影的滚动容器,仅在有更多内容时出现;横向条可选鼠标滚轮横向滚动、按住拖拽滚动,到两端自动交还页面滚动。

基础用法

标签 1 标签 2 标签 3 标签 4 标签 5 标签 6 标签 7 标签 8 标签 9 标签 10 标签 11 标签 12 标签 13 标签 14 标签 15 标签 16
Basic.vue

纵向

第 1 行内容
第 2 行内容
第 3 行内容
第 4 行内容
第 5 行内容
第 6 行内容
第 7 行内容
第 8 行内容
第 9 行内容
第 10 行内容
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,以便屏幕阅读器识别该区域。

属性

属性类型默认值说明
ariaLabelstring"scrollable content"
axis"horizontal" | "vertical""horizontal"
classNamestring""
contentClassstring""
draggablebooleanfalseClick-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.
shadowColorstring"var(--color-background)"
shadowSizestring"2rem"
wheelboolean | "contain"falseWhen `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.