0

I came across a CSS selector with nesting square brackets like this in a library. Tried to search and understand what does it mean, but can't find any information. Can anyone explain it:

[['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]: {
    // CSS props here
}

Edit: it's in the style props of GlobalTheme component from emotion lib, the project using React.

3
  • I think that this is similar to your question. Commented Oct 26, 2021 at 14:13
  • Doesn't look like CSS to me, so this is probably some preprocessor syntax, I suppose. Commented Oct 26, 2021 at 14:23
  • @CBroe Oh, lemme edit a bit it's in the style props of emotion library and the project is React. Commented Oct 26, 2021 at 14:32

1 Answer 1

1

As stated here it is mostly used to style components.

Example from the documentation :

  import styled from '@emotion/styled'

const Child = styled.div({
  color: 'red'
})

const Parent = styled.div({
  [Child]: {
    color: 'green'
  }
})

render(
  <div>
    <Parent>
      <Child>green</Child>
    </Parent>
    <Child>red</Child>
  </div>
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.