[英]how to import all icons in Material Design from react-icons
I could not find anywhere in the documentation and on google how to use我在文档和谷歌上找不到任何地方如何使用
import * as MaterialDesign from "react-icons/"从“react-icons/”导入 * 作为 MaterialDesign
in the render fonction.在渲染函数中。
Thank you for understanding.谢谢你的理解。
That's a lot of bloat to import all those icons in a project.在一个项目中导入所有这些图标是很臃肿的。 If you're trying to get just the library for Material Design icons you can use something like @react-md/material-icons
.如果你想获得Material Design 图标的库,你可以使用类似@react-md/material-icons
东西。
yarn add @react-md/material-icons @react-md/icon
import { render } from "react-dom";
import {
AccessAlarmFontIcon,
AccessAlarmSVGIcon,
Rotation3DFontIcon, // the sprite name for this was 3d_rotation.svg
Rotation3DSVGIcon, // the sprite name for this was 3d_rotation.svg
HomeFontIcon,
HomeSVGIcon,
} from "@react-md/material-icons";
const App = () => (
<main>
<AccessAlarmFontIcon />
<AccessAlarmSVGIcon />
<Rotation3DFontIcon />
<Rotation3DSVGIcon />
<HomeFontIcon />
<HomeSVGIcon />
</main>
);
render(<App />, document.getElementById("root"));
Or just use或者只是使用
yarn add @material-ui/core @material-ui/icons
then call the icon然后调用图标
import MenuIcon from '@material-ui/icons/Menu'
and in your component just add <MenuIcon/>
.并在您的组件中添加<MenuIcon/>
。 There is a way to search for any Material Icon .有一种方法可以搜索任何Material Icon 。
To include all icons in one;将所有图标合二为一; You must use this code!您必须使用此代码!
import * as MaterialDesign from "react-icons/md";
To use an icon: ( <MaterialDesign.IconName /> )使用图标:( <MaterialDesign.IconName /> )
<MaterialDesign.MdHelp />
Note: Make sure you have installed the react-icons package!注意:确保你已经安装了 react-icons 包!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.