
Description
react-scrollchor is a React component that scrolls smoothly to #hash links on the page. The name is a mix of Scroll and Anchor. You give the link the id of the element to scroll to, and when it is clicked the page animates to that element. It works within the window or within any scrollable parent container. Props let you choose the scrolling target, customise the animation with the easing functions the package exports, which are easeOutQuad, swing and linear, add extra pixels of offset, and run your own code before scrolling through the beforeAnimate prop. Other props are passed on to the underlying anchor tag, except href and onClick, which the component manages. The package ships TypeScript type definitions for editor autocompletion. It needs React 16.8.0 or later, the first version with hooks, and is installed from npm or yarn.…
Highlights
- Smooth scroll to #hash anchor links
- Works inside scrollable containers
- Customizable easing and pixel offset
- beforeAnimate hook before scrolling
- TypeScript definitions included
Ratings & Reviews
No ratings yet
Be the first to rate react-scrollchor.
People also visit
react-scrollchor FAQ
What does react-scrollchor do?
It is a React component that smoothly scrolls the page to the element matching a #hash link.
How do I install it?
With npm or yarn. Your project needs React 16.8.0 or later.
Can I change the animation?
Yes. The animate prop customises the smooth scrolling, and the package exports the easeOutQuad, swing and linear easings.
Can it scroll inside a container?
Yes. Set the target prop to the scrollable element. If no target is given or found, it scrolls the page.
Does it include types?
Yes, it ships TypeScript type definitions.
What are the best react-scrollchor alternatives?
Popular alternatives to react-scrollchor include react-scroll, react-animate-on-scroll and react-scroll-up. See all react-scrollchor alternatives




















