Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do psuedo selectors work in styled-components the same as in css with unicode characters

I have the following styled-component, and I am trying to add a unicode character \00d7 as the content for a pseudo selector, which is a cross or close icon.

However this doesn't seem to work as it would in css. Of course I can use an svg for this close icon as an alternative, I was just curious if this is possible with styled-components? It seems to allow blank pseudo selector's though e.g. ''

const Close = styled.span`
  color: pink;
  &:before {
    content: '\00d7';
  }
`
like image 445
svnm Avatar asked May 22 '17 15:05

svnm


People also ask

Are styled components scoped?

Creating Global StylesNormally, styled-components are scoped to a particular class or component but the createGlobalStyles function removes that limitation and allows whatever style you declare within it to be applied globally across your app.

What is a styled DIV?

styled-components creates a React component, which renders an HTML tag corresponding to the property in the styled object. Button will create and render a button HTML tag, while Div will create and render a div tag. They are components, so we can pass props to them.


2 Answers

I think you need a combination of the two comments:

content: "\\d7"

This works for me.

like image 103
barro32 Avatar answered Oct 03 '22 13:10

barro32


Try updating the reference to:

content: '×';

Further alternative encoding formats are available on https://brajeshwar.github.io/entities/.

like image 45
Conan Avatar answered Oct 03 '22 13:10

Conan