Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove caret from dropdown nav item in React Bootstrap

I have been trying to remove the caret from the NavDropdown component with bootstrap 4 and react, however I have had no luck. This is my react and css, not sure what's going wrong. Thanks.

<Navbar expand="lg">
        <Navbar.Toggle aria-controls="basic-navbar-nav" />
        <Navbar.Collapse id="basic-navbar-nav">
          <Nav className="mr-auto">
          <NavDropdown title="ENGAGEMENT" id="basic-nav-dropdown" show={false} className="noCaret">
              <NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
              <NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
              <NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
              <NavDropdown.Divider />
              <NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
            </NavDropdown>
          </Nav>
        </Navbar.Collapse> 
</Navbar>
.caret {
  display: none !important;
}

.navbar .dropdown-menu:after{
  display:none !important;
 }

 .dropdown-toggle.noCaret:after {
  display: none !important;
like image 960
nisha Avatar asked Apr 14 '20 20:04

nisha


People also ask

How do I remove the drop down toggle icon?

In Bootstrap 4, you can remove the dropdown arrow which is called caret by declaring a $enable-caret SASS variable and setting it to false : $enable-caret: false; This overrides the default value of true set in the Bootstrap's _variable.

How Use dropdown in bootstrap React?

We can use the following approach in ReactJS to use the react-bootstrap Dropdown Component. Dropdown Props: alignRight: It is used to align the menu to the right side of the Dropdown toggle. as: It can be used as a custom element type for this component.

How do I remove a dropdown caret from bootstrap?

Every Bootstrap dropdown button or link has an ::after selector in CSS. ::after selector is often used to insert some text after the content of the element. In this case, the content is a dropdown arrow. To remove it, just make the content go 'none'.

How do I remove arrow from React dropdown?

You can hide the dropdown arrow from the DropDownButton by adding class e-caret-hide to DropDownButton element using cssClass property.

What is a dropdownbutton in react-bootstrap?

The basic Dropdown is composed of a wrapping Dropdown and inner <DropdownMenu>, and <DropdownToggle>. By default the <DropdownToggle> will render a Button component and accepts all the same props. Since the above is such a common configuration react-bootstrap provides the <DropdownButton> component to help reduce typing.

How to remove caret form dropdown button in Bootstrap 4?

In Bootstrap 4 you can remove caret form dropdown button by setting $enable-caret sass variable false. But you must set this variable before importing the bootstrap sass file. // Your variable overrides $enable-caret: false // Bootstrap and its default variables @import "node_modules/bootstrap/scss/bootstrap";

How do I remove the caret from a drop down menu?

It's done in css. Do something like that: You may need an !important at the end of that declaration depending on your load order. You can remove the caret in Bootstrap 4 by removing the dropdown-toggle class from your element. So instead of this: This won't have any side affects and it will still function properly as a dropdown.

Does react-bootstrap support keyboard navigation?

We do implement some basic keyboard navigation, and if you do provide the "menu" role, react-bootstrap will do its best to ensure the focus management is compliant with the ARIA authoring guidelines for menus. The basic Dropdown is composed of a wrapping Dropdown and inner <DropdownMenu>, and <DropdownToggle>.


2 Answers

You can disable the caret by using id as well

 #dropdown-basic::after{
      display: none; 
   }
like image 83
Deadpool Avatar answered Oct 27 '22 09:10

Deadpool


This works for me, using default bootstrap classes.

    .dropdown-toggle::after {
      display: none;
    }
like image 32
user2809286 Avatar answered Oct 27 '22 11:10

user2809286