styled-jsx icon indicating copy to clipboard operation
styled-jsx copied to clipboard

feature: `scoped` apply styles to the elements of its parent(s) and children

Open mittalyashu opened this issue 4 years ago • 0 comments

The scoped attribute has been deprecated, they might re-introduce it in future.

Use case

const testComponent = () => {
  return (
    <>
      <header className="card card-header">
        <div>
          Title
        </div>
        <Button>
          Create
          <style jsx scoped>{`
            .btn {
              width: 200px;
            }
          `}</style>
        </Button>
      </header>
      <footer className="card card-footer">
        <Button>
          Big CTA
          <style jsx scoped>{`
            .btn {
              width: 100%;
            }
          `}</style>
        </Button>
      </footer>
    </>
  );
};

mittalyashu avatar Feb 19 '21 17:02 mittalyashu