I am looking to implement smooth scrolling specifically on one page in my Next.js application, such as my blog. Instead of applying it to the entire site through the globals.css
file, I need a way to inject scroll-behavior: smooth;
into the html tag only for certain pages.
I've heard that this can be achieved using CSS modules, but I'm unsure of how to do it. I came across an explanation on how to target css classes for this purpose here, but I'm unclear on how to apply it to the html tag in my scenario.
Any guidance or suggestions would be greatly appreciated!
I have attempted the following:
.foo :global {
html {
scroll-behavior: smooth;
}
}
and also this:
html :global {
.foo {
scroll-behavior: smooth;
}
}
However, I encountered the following error:
Syntax error: Selector "html :global" is not pure (pure selectors must contain at least one local class or id)