1 | initial version |
The process for dynamically loading mui icons from mui in TypeScript involves the following steps:
npm install @mui/material-icons
import Icon from '@mui/material/Icon';
import { createSvgIcon } from '@mui/material/Icon';
const CustomIcon = createSvgIcon(
<>
// add SVG paths here
</>,
'CustomIcon'
);
import React from 'react';
import Icon from '@mui/material/Icon';
import { createSvgIcon } from '@mui/material/Icon';
const CustomIcon = createSvgIcon(
<>
// add SVG paths here
</>,
'CustomIcon'
);
export default function MyComponent() {
return (
<div>
// render the custom icon
<Icon>
<CustomIcon />
</Icon>
</div>
);
}