Scroll Progress
Vue 已实现 · 还原验收 0/1 · 上游演示 · 固定版本源码
预览
Section 1
Section 2
Section 3
Section 4
Section 5
Section 6
Section 7
Section 8
Section 9
Section 10
Section 11
Section 12
Section 13
Section 14
Section 15
Section 16
Section 17
Section 18
用法
vue
<script setup lang="ts">
import { ScrollProgress } from 'beui-vue'
import { useTemplateRef } from 'vue'
const region = useTemplateRef('region')
</script>
<template><div class="progress-frame"><ScrollProgress :container="region" :fixed="false" :height="3" data-testid="progress-bar" /><div class="circle"><ScrollProgress :container="region" variant="circle" :size="36" /></div>
<div ref="region" role="region" aria-label="Sections" tabindex="0" class="scroller"><div v-for="section in 18" :key="section" class="section">Section {{ section }}</div></div>
</div></template>
<style scoped>.progress-frame { position: relative; width: 100%; max-width: 32rem; overflow: hidden; border: 1px solid var(--beui-border); border-radius: 1rem; background: var(--beui-card); } .scroller { height: 16rem; overflow: auto; padding: 1rem; box-sizing: border-box; } .circle { position: absolute; right: .75rem; top: .75rem; z-index: 1; padding: .25rem; border-radius: 50%; background: var(--beui-background); pointer-events: none; } .section { border-radius: .5rem; padding: 1rem .75rem; margin-bottom: .75rem; background: var(--beui-muted); color: var(--beui-muted-foreground); font-size: .875rem; }</style>API
variant 选择 bar 或 circle。默认跟踪页面,使用 container 指定滚动元素或 progress 传入 0 到 1 的数值或 MotionValue。支持 spring、fixed、height、size 和 thickness。