Here's an example of my Next.JS component code:
export function LoginButton({children, className, ...props}){
return (
<>
<style jsx>
{`
.loginButton {
padding: .75rem 2rem;
width: 100%;
border-radius: 2rem;
background: var(--primary);
color: var(--back);
font-size: 2rem !important;
}
.loginButton:hover i {
transform: translateX(.5rem);
}
`}
</style>
<button className={`loginButton ${className}`} {...props}>
{children}
</button>
</>
)
}
Now unfortunately, the problem is. All the JSX styles are being applied nicely to the button element (as it has its own JSX class), but unfortunately, not the children that had been fed into the component.
Here's an example of how I'm using this code:
<LoginButton className="flex center gap1">
<h3>
Sign in
</h3>
<i className="bx bxs-right-arrow-alt"></i>
</LoginButton>
The element that I am putting in is not getting the JSX styles for the button. I've tried various solutions like cloning the elemenets, updating JSX to global but everything failed.
What else could I do to automatically apply the styles to the component's children? Many thanks.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/QJ9sf2u
Comments
Post a Comment