John
John

Reputation: 21

Change arrow icon in 'ant design'

I created a menu with submenus with ant design and want to change the expanded arrow icon without important styling

Image 1.

enter image description here

Desirred Icon ->

enter image description here

https://ant.design/components/menu/

<Menu
  onClick={this.handleClick}
  defaultSelectedKeys={['1']}
  mode="inline"                          
>
 <SubMenu title={<span>Home Page</span>}>
     <Menu.Item>1</Menu.Item>
     <Menu.Item>2</Menu.Item>
 </SubMenu>
</Menu>

Upvotes: 2

Views: 10030

Answers (2)

deweyD
deweyD

Reputation: 39

Not sure if this is too late, though I see a comment asking if a solution was ever found. If you utilize the Menu component's "expandIcon" parameter you can pass down your own custom icon into the SubMenu component:

 <Menu
        expandIcon={<YourCustomIcon/>}
        selectedKeys={current}
        mode="inline"
    >
        <SubMenu style={{ width: 150 }} key="sub1">
            <Menu.Item key="1">Option 1</Menu.Item>
            <Menu.Item key="2">Option 2</Menu.Item>
            <Menu.Item key="3">Option 3</Menu.Item>
            <Menu.Item key="4">Option 4</Menu.Item>
        </SubMenu>
    </Menu>

Upvotes: 3

Fatemeh Qasemkhani
Fatemeh Qasemkhani

Reputation: 2042

Put this code in your css file that is placed after the antd css file:

.ant-menu-submenu > .ant-menu-submenu-title .ant-menu-submenu-arrow::before {
  content: '';
  position: absolute;
  background: unset !important;
  background-image: unset !important;
  width: 0 !important;
  height: 0 !important;
  border-style: solid;
  border-width: 6px 0 6px 6px;
  border-color: #00d2be transparent transparent transparent;
  transition: transform 0.3s ease-in-out !important;
  transform: rotate(45deg) !important;
  border-radius: 0 !important;
  left: 0;
  top: 50%;
}

.ant-menu-submenu-open > .ant-menu-submenu-title .ant-menu-submenu-arrow::before {
  content: '';
  position: absolute;
  background: unset !important;
  background-image: unset !important;
  width: 0 !important;
  height: 0 !important;
  border-style: solid;
  border-width: 6px 0 6px 6px;
  border-color: #00d2be transparent transparent transparent;
  transition: transform 0.3s ease-in-out !important;
  transform: rotate(-45deg) !important;
  border-radius: 0 !important;
  left: 0;
  top: 50%;
}

.ant-menu-submenu-inline > .ant-menu-submenu-title .ant-menu-submenu-arrow::after,
.ant-menu-submenu-vertical-left > .ant-menu-submenu-title .ant-menu-submenu-arrow::after,
.ant-menu-submenu-vertical-right > .ant-menu-submenu-title .ant-menu-submenu-arrow::after,
.ant-menu-submenu-vertical > .ant-menu-submenu-title .ant-menu-submenu-arrow::after {
  content: none !important;
}

Upvotes: 1

Related Questions