I have created a one-page website using tailwindcss
and React
. In the prototype I use the tailwindcss
class "scroll-smooth" and it works. In React
the class "scroll-smooth" does not work, but what is the reason?
https://tailwindcss.com/docs/scroll-behavior#basic-usage
When I click "Why" on Navigation i jump to the section "why" but not smoothly:
function App() {
return (
<div className="App">
<div className="relative">
<div className="flex flex-col scroll-smooth">
<HomeNav />
<HomeHero />
<section id="why" className="flex flex-col items-center px-6 pt-20">
...
</section>
<HomeFooter />
</div>
</div>
</div>
);
}
Solution:
I think TailwindCss
Class "scroll-smooth" it doesn't work on react. So I use the NPM
package "react-scroll" with which it works great and I probably have less compatibility worries.