-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[icons] Support getting Icon Components as Arrays, by styles and tags #42450
Comments
Hey @TheOneTheOnlyJJ, thanks for the proposal. As you pointed out, this is a big change that we'll need to consider. In the meantime, you should be able to build the icon selection functionality in userland. This is how it currently works in the Material Icons docs page:
|
@TheOneTheOnlyJJ I'm closing this issue since there's a solution that can be implemented in userland and for now, we don't think this is a necessary addition to the |
Summary
In the context of an issue I opened for the MUI X package mui/mui-x#13206 I have mentioned the necessity to add a new utility function
getIcons
to themui/icons-material
package. This is because I need to create an icon selection component from which a user could select any of the Material Icons available. There is no way to import all of them at once, and writing out thousands of imports by hand is not feasible.Examples
In order to also cover filtering icons by their styles and tags, here is the API I propose (extracted from my MUI X issue mentioned above):
The
styles
argument is optional and, if missing, every style will be included in the output. It is a string array that can have any of the following optionsfilled
,outlined
,rounded
,two tone
andsharp
. These could additionally also be exported as enums to be used in code conveniently.The
tags
argument is also optional, and its filtering will apply together with thestyle
filter. It is an object that must have either theanyOf
or theallOf
keys that map to string arrays. They should not be both supported at the same time, resulting in an exception being thrown. Using the argument withanyOf
option will return all the icons that have at least one of the tags in the list. Using it with theallOf
option will return only the icons that have all the tags from the given tag list.Additionally, a function that allows getting all tags for a specific icon (maybe call it getIconTags) should also be available for flexibility (to show the user the keywords/tags a specific icon can be found by), but this would require an internal ID for every icon to be passed as an argument to that function. I am not that accustomed to the internals of the icons package, so I do not know how difficult such an addition would be.
If this API addition would require profound internal modifications of the
mui/icons-material
package, I may suggest batching it with the addition of support for Material Symbols (see #32846 for details) in MUI v7, as that will also impact the package substantially.Motivation
There's no way to easily get Material Icons as components en masse (My use case requires this for user selection).
Search keywords: material icon symbol array style tag
The text was updated successfully, but these errors were encountered: