Skip to content
DocsErrorsNested `<style jsx>` tags

Nested `<style jsx>` tags

Why This Error Occurred

You have nested <style jsx> tags in a component. <style jsx> tags must be at the root of a styled-jsx scope.

Possible Ways to Fix It

Before

example.js
const Component = () => (
  <div>
    <p>
      Hello world
      <style jsx>{`
        p {
          color: white;
        }
      `}</style>
    </p>
    <style global jsx>{`
      body {
        background: black;
      }
    `}</style>
  </div>
)

After

example.js
const Component = () => (
  <div>
    <p>Hello world</p>
    <style jsx>{`
      p {
        color: white;
      }
    `}</style>
    <style global jsx>{`
      body {
        background: black;
      }
    `}</style>
  </div>
)