Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Icon component instead of separate Icon components for each icon #44492

Closed
pradipjs opened this issue Nov 21, 2024 · 2 comments
Closed
Labels
package: icons Specific to @mui/icons support: question Community support but can be turned into an improvement

Comments

@pradipjs
Copy link

pradipjs commented Nov 21, 2024

Summary

Material Icons provide separate icon components for each icon.
i.e. import { Abc } from '@mui/icons-material/Abc';

In some of cases, people require some kind of generic icon component where we just need to pass Icon Name and it will render that icon. i.e. Dynamic Icon Rendering.

There's some issue with dynamic import with next on Icon imports.
Better If we can have that Icon component with name property.

Examples

Current :
import { Abc } from '@mui/icons-material/Abc';
<Abc size={'small'} ... />

Expected :
import Icon from '@mui/icons-material'; // Or Whatever
<Icon name="Abc" size={'small'} ... />

Motivation

Most common use cases for this is, where icons are dynamic or coming from server side. Where we cannot map icons with each icon name.

Search keywords: Icon component

@pradipjs pradipjs added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 21, 2024
@siriwatknp
Copy link
Member

Thanks for your feedback!

The reason <Icon name="Abc" size={'small'} ... /> won't fly is that it's not tree-shakable. If you have 1000+ icons, they will all end up in the bundle size.

@siriwatknp siriwatknp added support: docs-feedback Feedback from documentation page and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 21, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@pradipjs How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@siriwatknp siriwatknp added support: question Community support but can be turned into an improvement package: icons Specific to @mui/icons and removed support: docs-feedback Feedback from documentation page labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: icons Specific to @mui/icons support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants