Next.js Discord

Discord Forum

How scroll with smoth animation using anchor and <Link> component ?

Unanswered
Fire ant posted this in #help-forum
Open in Discord
Fire antOP
Hi, i want to scroll with smoth animation when i m using the <Link> component, because on my case i don't know how to do, it's doesnt have animation and it position the element to the top, i want it centered.. Thank you !

6 Replies

Fire antOP
Thank you, why i need to use <a> tag and not <Link> tag ? Other thing, i have a fixed element (the header) i need more marging when the anchor make the app scroll into the element, there is something i could do ? I just do not want to make strange customized code ^^
Fire antOP
Hmm ok, i used useEffect, it's working when i click on the link button, now the difficult part it's just to add the extra marging when i refresh the url with #anchor (without clicking on the link element),