coreui / coreui-free-react-admin-template

Open source admin template based on Bootstrap 5 and React.js
https://coreui.io/product/free-react-admin-template/
MIT License
4.54k stars 2.26k forks source link

`CNavGroup` icons not working on Coreui Free Admin Template ReactJS 4.3.0 #400

Closed Alan-Graton closed 1 year ago

Alan-Graton commented 1 year ago

Versions

Problem Description

My _nav file is like this:

{
    component: CNavItem,
    name: 'Home',
    to: '/index',
    icon: <CIcon icon={cilHome} customClassName="nav-icon" />,
  },
{
    component: CNavGroup,
    name: '1',
    toggler: 'Companies',
    icon: <CIcon icon={cilBuilding} customClassName="nav-icon" />,
    items: [
      {
        component: CNavItem,
        name: 'New Company',
        to: '/Companies/NewCompany',
        icon: <CIcon icon={cilBuilding} customClassName="nav-icon" />,
      },
      {
        component: CNavItem,
        name: 'List',
        to: '/Companies/ListCompany',
        icon: <CIcon icon={cilListRich} customClassName="nav-icon" />,
      },
    ],
  },

I'm trying to add an icon in my CNavGroup element, but it won't render. There is no error or warning, it simply doesn't render. It works fine on CNavItem though, and I've seen people(and in your templates live previews) CNavGroups with icons.

I've tried working with the <CIcon />, <img /> and <svg /> components, but none of those worked.

My Current Sidebar:

Current Sidebar

Coreui Free Admin ReactJS Template Sidebar(Live Preview)

Coreui Sidebar

Am I doing something wrong?

Thanks in advance!

Alan-Graton commented 1 year ago

I just realize that the toggler prop was overriding the icon prop. After using the name for displaying the page name the icon was rendered.