styled-components / xstyled

A utility-first CSS-in-JS framework built for React. 💅👩‍🎤⚡️
https://xstyled.dev
MIT License
2.28k stars 105 forks source link

cssProperty and pseudo-element #251

Closed iManu closed 3 years ago

iManu commented 3 years ago

💬 Questions and Help

Hello Greg,

As we use xstyled in a new project, we're glad to perform with the tool :)

We trying using pseudo element like ::before in the way it is described in the doc, but we cannot make it work.

The code of utilities :

import { style, x } from '@xstyled/styled-components'

export const pseudoEl = x.extend(
  style({
    prop: 'pseudoEl',
    cssProperty: () => ({
      '&::after': {
        content: 'TEST',
        fontSize: '16px',
        position: 'absolute',
        zIndex: 1,
        top: 0,
        left: 0,
      },
    }),
  }),
)

then in component import { pseudoEl as p } from 'utilities'

and in jsx <p.div pseudoEl>Expect ::after in DOM</p.div>

but nothing happens, what is wrong with our code ?

Capture d’écran 2021-04-27 à 11 18 14

gregberge commented 3 years ago

Hello @iManu, it is a styled-components problem, content must be content: '"TEST"' with double quotes. https://twitter.com/peduarte/status/1361369526613475335