A
A
Alexander2021-06-09 14:17:26
css
Alexander, 2021-06-09 14:17:26

How to add icon for content (:before) styled-components?

Hello, please tell me how to add an icon for content before in styled-components?

Source:

import { IoIosArrowBack} from 'react-icons/io'

 &::before {
    content: url(IoIosArrowBack);
    display: block;
    width: 20px;
    height: 20px;
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria, 2021-06-14
@axrising

Convert the IoIosArrowBack icon to a link that content can use

const reactSvgComponentToMarkupString = (Component, props) =>
  `data:image/svg+xml,${encodeURIComponent(
    renderToStaticMarkup(createElement(Component, props))
  )}`;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question