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

后端 未结 3 1151
心在旅途
心在旅途 2021-02-11 13:06

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

3条回答
  •  粉色の甜心
    2021-02-11 13:52

    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/)

提交回复
热议问题