Loading page…
Pitch
Description
Comments
eszett is a build-time plugin for CSS scoping in React applications, inspired by styled-jsx. It generates unique class names for HTML elements, making it perfect for Next.js projects. With eszett, enjoy writing normal css while maintaining component encapsulation, allowing for global styles when needed.
eszett: Explicit CSS Scopes for React
Unlock the power of scoped styling in your React applications with eszett, a build-time only plugin inspired by styled-jsx. This solution is designed for compatibility with React Server Components, offering a seamless integration for applications built with Next.js.
sz template literal you cann pass the generated classNames to child components.To get started with eszett, you simply import it into your component:
import eszett from "eszett";
async function Header() {
return (
<header className='header'>
<h2>Hello World</h2>
<style href={eszett} precedence="eszett">{`
.${eszett} {
&.header {
background: blue;
}
}
`}</style>
</header>
);
}
import eszett from "eszett";
async function Component(props) {
return (
<div className="wrapper">
{props.children}
<style>{`
.${eszett}.wrapper strong {
color: red;
}
`}</style>
</div>
);
}
sz tagged template literal.import eszett, { sz } from "eszett";
import Link from "next/link";
async function Component() {
return (
<>
<Link href="/home" className={sz`link`} />
<style>{`
.${eszett}.link {
color: red;
}
`}</style>
</>
);
}
No comments yet.
Sign in to be the first to comment.