Move to Top Button

A button that appears when the user scrolls down the page, allowing them to quickly return to the top.

Preview

Scroll down to see the magic!

This is a demo page to showcase the MoveToTop component. Scroll down and watch the button appear with a cool animation!

Installation

1. Run the following command in your terminal:
npx shadcn@latest add @refinery/move-to-top-button

API Reference

Component props
NameTypeDescription
No documented props yet.

Usage Recommendations

For the best experience, use the 'Geist' theme...
Always ensure the component is properly styled and accessible.
Design Notes

This component uses a scroll event listener to track the user's scroll position and determine when to show the button. The button itself is styled as a circular icon with a progress indicator around it that fills up as the user scrolls down. When clicked, it smoothly scrolls the user back to the top of the page. The progress indicator is implemented using an SVG circle with a stroke dash offset that updates based on the scroll progress. you can swap the 'fixed' position with absolute-relative combo if you want the button to be positioned relative to a specific container instead of the viewport. The component is designed to be responsive and works well on both desktop and mobile devices. It is direction aware, such that when you go down, it shows chevronUp and while going up it shows arrowDown icon, while at default top and bottom positions, it shows chevronUp and arrowDown respectively.