The useStyles$ can style entire page but it couldn't scope to components.
The useStylesScoped$ can style scoped to the component but it couldn't style its child components.
So I added one more thing, the useStyleWithScope$ that introduces the :scope pseudo class to scope styles manually.
By using this function, you can use :scope pseudo class to be replaced with .${scopeId}.
:scope {
background: red
}
The above css is to be like this:
.⭐️5yhoz-0 {
background: red
}
Use cases and why
While the useStylesScoped$ put the scopeId to every rules in the CSS, this function can select rules to put it.
So you can scope styles to the component and its children such as <Link> too.
Overview
What is it?
Description
The
useStyles$
can style entire page but it couldn't scope to components. TheuseStylesScoped$
can style scoped to the component but it couldn't style its child components. So I added one more thing, theuseStyleWithScope$
that introduces the:scope
pseudo class to scope styles manually.By using this function, you can use
:scope
pseudo class to be replaced with.${scopeId}
.The above css is to be like this:
Use cases and why
While the
useStylesScoped$
put thescopeId
to every rules in the CSS, this function can select rules to put it. So you can scope styles to the component and its children such as<Link>
too.Checklist: