How to use an SVG file in a SvgIcon in Material-UI

后端 未结 2 1509
终归单人心
终归单人心 2021-02-11 13:09

I\'ve got an SVG file and I want to make an SvgIcon component out of it, how should I do that?

In the documentation, all the examples use either predefined Material Icon

2条回答
  •  感情败类
    2021-02-11 14:06

    is an SVG path, i.e. the internal bits of the SVG. the SvgIcon component really should be able to take a path, but it doesn't :(

    instead you can create a component like https://github.com/callemall/material-ui/blob/56c113217d7d05d8bb0712771b727df81984d04b/src/svg-icons/action/home.js

    with your svg source in place of the path. (I recommend minifying it a bit using https://jakearchibald.github.io/svgomg/)

提交回复
热议问题