Custom Style on React-Bootstrap's Dropdown Menu component

霸气de小男生 提交于 2019-12-06 06:20:30

Add a custom className to <MenuItem></MenuItem> and edit it by appending a a at the end of className in your .css file while customising.

In your .js file:

<MenuItem className="dropdown-link"> DaItem </MenuItem>

In your .css file: (Note the a in the selector)

.dropdown-link a {background: red; color: yellow;}

P.S: You may need to add !important in .css

Thank you all, I found an way to this! I was able to access the specific menu by including [aria-labelledby = ddown] (ddown is my dropdown's custom class) on the CSS like so:

.dropdown-menu[aria-labelledby = ddown] {
  background-color: lightblue;
  max-width: 80px; //This, by the way, is not working for some reason.
  border-radius: 0;
  margin: 0;
}

you use DropDown.Menu and DropDown.Item in the following way

<Dropdown.Menu className="my-dropdown">
  <Dropdown.Divider />
  <Dropdown.Item className="itemxx" href="#books">Books</Dropdown.Item>
  <Dropdown.Item>className="itemxx" href="#podcasts">Podcasts</Dropdown.Item>
</Dropdown.Menu>

and then add your customs CSS like

.my-dropdown {
  border-radius: 0;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!