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

Add icon template to Menu components #2733

Closed
manuelpoelzl opened this issue Apr 9, 2022 · 5 comments
Closed

Add icon template to Menu components #2733

manuelpoelzl opened this issue Apr 9, 2022 · 5 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@manuelpoelzl
Copy link

I'm submitting a ... (check one with "x")

[ ] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

I'm currently having quite a bit of trouble using multiple icon libraries with PrimeReact, which leads me to write this feature request.

I think it would be quite good to say goodbye to icons as class names, or at least they would no longer be the preferred variant in React.

In my case, for example, I use the react-icons module, which combines several icon libraries, but unfortunately I can't use them in PrimeReact, because all icons in any menus have to be a string, or specified as a class in an element.

Therefore I think it would be quite good to have a support for icon components, which allows to use different libraries.

Of course there is the possibility to install each icon library separately and then import it into the CSS so that you then have the classes available, but the variant as a component and thus also the support of react-icons would be much nicer in my opinion.

@melloware melloware added the Type: New Feature Issue contains a new feature or new component request label Apr 10, 2022
@melloware
Copy link
Member

Can you post an example snippet of code using React Icons you would expect to work correctly?

@mertsincan
Copy link
Member

Hi @manuelpoelzl,

Most Primereact components have templating structures for icons. Which component are you using?

Exp;

icon="pi pi-home" | icon="..." (string type)
icon={<YourIconComponent />}
icon={(props) => <YourIconComponent />}

@manuelpoelzl
Copy link
Author

Sure, let's say I have a menu, and an item there should have an icon. Let's assume a special case, a hot air balloon.

Then it would be great if something like that would be possible:

import {GiAirBalloon} from "react-icons/gi";

 const menuItems: MenuItem[] = [
        {
            icon: <GiAirBalloon/> /*currently needs to be the icon class name as string*/
            label: t("addNew"),
            command(e: MenuItemCommandParams) {

                setIsPanelVisible(true);
            }
        }
    ];

I see that this is already possible in buttons or even in the sidebar toolbar, as demonstrated here:

<Button icon={<GiAirBalloon/>} />
icons={() => (
  <button type={"submit"} form={"createSiteForm"}
     className="p-sidebar-close p-link">
         <FaSave className={"p-sidebar-close-icon"}/>
  </button>
)}

So I think that would be a good feature if that was possible in menu items as well.

@mertsincan mertsincan self-assigned this Apr 10, 2022
@mertsincan mertsincan changed the title Support for icon components instead of class names Add icon template to Menu components Apr 10, 2022
@mertsincan mertsincan added this to the 8.0.0-rc.2 milestone Apr 10, 2022
@mertsincan
Copy link
Member

mertsincan commented Apr 10, 2022

Thanks a lot for your update!

All components using MenuItem API;

  • BreadCrumb
  • ContextMenu
  • Dock
  • MegaMenu
  • Menu
  • Menubar
  • PanelMenu
  • SlideMenu
  • SpeedDial
  • SplitButton
  • Steps
  • TabMenu
  • TieredMenu

@manuelpoelzl
Copy link
Author

Thank you very much for considering this!

@mertsincan mertsincan added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add Type: New Feature Issue contains a new feature or new component request labels Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

3 participants