Skip to content
Latestv1.0.63

BackTop ​

Used for long pages. Clicking the button smoothly scrolls back to the top of the page.

Basic Usage ​

The simplest usage, shown by default after scrolling 200px.

Basic Usage

Progress Indicator (Advanced) ​

YhBackTop features an industry-leading progress ring. Through the dynamic ring bar around the button, users can intuitively perceive the current physical position relative to the top of the article.

Progress Preview

Custom Content & Styles ​

Customize button content through slots and adjust display position and progress bar color through props.

Custom Content

Advanced Features ​

1. Kinetic Progress Ring ​

By syncing the page scroll height with the SVG ring circumference at high frequency, an immersive "scroll equals feedback" experience is achieved. The ring uses stroke-dashoffset linear mapping, ensuring the ultimate balance between performance and visuals.

2. Smart Viewport Adaptation ​

Not limited to window global scrolling. When placed inside a container with overflow: scroll combined with the target prop, it can precisely control the return logic for local areas.

3. Cubic Easing Animation ​

Built-in Cubic Easing function makes the scroll-back action more aligned with physical perception, giving more "weight" than simple linear displacement.

Use in Nuxt ​

YhBackTop is perfectly adapted for Nuxt auto-import.

Use in Nuxt

API ​

Props ​

PropDescriptionTypeDefault
visibility-heightOnly shown when scroll height reaches this valuenumber200
targetContainer selector, not needed for full-screen scrollingstring—
rightDistance from the rightnumber40
bottomDistance from the bottomnumber40
show-progressWhether to show the progress ringbooleantrue
progress-colorProgress ring color; falls back to current text color when emptystring''
durationScroll-back animation duration (ms)number400
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events ​

Event NameDescriptionParameters
clickTriggered when button is clicked(evt: MouseEvent)

Slots ​

Slot NameDescriptionSlot Props
defaultCustom back-to-top trigger content.None

Expose ​

This component does not expose public instance methods or properties.

Theme Variables ​

YhBackTop supports themeOverrides, but it does not currently expose dedicated component-scoped CSS variables. Its rendered styles mainly consume shared global theme tokens such as background color, primary color, border color, and fill color.

Type Exports ​

NameDescription
YhBackTopPropsProps type for YhBackTop
YhBackTopEmitsEmits type for YhBackTop
YhBackTopSlotsSlots type for YhBackTop
YhBackTopInstancePublic instance type for YhBackTop

Released under the MIT License.