React-Bootstrap API Dropdown
Last Updated :
20 Nov, 2023
React-bootstrap is a front-End Stylesheet library. It replaces the Bootstrap JavaScript into completely a react component. It creates a seamless front-end development experience.
In this article, we will see the React-Bootstrap API Dropdown. The dropdown components are generally created when we provide a list of items to choose from.
React-Bootstrap API Dropdown Props:
- bsPrefix: This changes the component's CSS base class name and modifier class names prefix.
- drop: It sets the direction and location of the menu with respect to its to it's Toggle.
- as: It helps to customize the element or to change the element type.
- show: It is a boolean value. It determines whether the Dropdown is visible or not.
- onToggle: It is a callback function which gets triggered when the Dropdown wishes to change visibility.
- onSelect: It is a callback function which gets triggered when a menu item is selected.
- focusFirstItemOnShow: It controls the the focus behavior for when the Dropdown is opened.
- autoClose: It determines the auto close behaviour of the dropdown.
Syntax:
<Dropdown>...</Dropdown>
Steps to create React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the required module using the following command:
npm install react-bootstrap bootstrap
Project Structure: It will look like the following.

Example 1: In this example, we are using the "id" and "drop" props of dropdown API in App.js file
JavaScript
import Dropdown from 'react-bootstrap/Dropdown';
import 'bootstrap/dist/css/bootstrap.min.css';
function App() {
return (
<div className="App text-center">
<h1 class="text-success">GeeksforGeeks</h1>
<h3>React-Bootstrap API Dropdown</h3>
<Dropdown drop='down-centered'>
<Dropdown.Toggle id="articles" variant="success">
Articles
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href="#/web-dev">Web Development</Dropdown.Item>
<Dropdown.Item href="#/software-testing">Software Testing</Dropdown.Item>
<Dropdown.Item href="#/python">Python</Dropdown.Item>
<Dropdown.Item href="#/linux">Linux</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
);
}
export default App;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Example 2: In this example, we are creating a dropdown component by using the "align" and "autoClose" props in App.js file.
JavaScript
import Dropdown from 'react-bootstrap/Dropdown';
import 'bootstrap/dist/css/bootstrap.min.css';
function App() {
return (
<div className="App text-center">
<h1 class="text-success">GeeksforGeeks</h1>
<h3>React-Bootstrap API Dropdown</h3>
<Dropdown align="start" autoClose="inside">
<Dropdown.Toggle id="languages">
Programming Languages
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href="#/java">Java</Dropdown.Item>
<Dropdown.Item href="#/c++">C++</Dropdown.Item>
<Dropdown.Item href="#/python">Python</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
);
}
export default App;
Output:

Similar Reads
React-Bootstrap Dropdown items React Bootstrap Dropdown Items is used to provide items in a dropdown. Dropdown is a kind of button; when the user clicks on it, it opens and shows the content present in it. So in React Bootstrap, Dropdown is by default present; we just need to add items by using DropDown items. React Bootstrap Dro
2 min read
React-Bootstrap Dropdowns AutoClose React-Bootstrap Dropdown Autoclose is a feature that allows you to manage how dropdown menus automatically close. By default, when a menu item is selected or when a user clicks outside the dropdown, it closes. React-Bootstrap Dropdowns AutoClose Autoclose attributes:true: By using this property the
2 min read
React-Bootstrap Dark dropdowns React Bootstrap Dark Dropdowns are used for dark screen User Interfaces. In this article we are going to implement dark Dropdowns using React Bootstrap Dark Dropdown which contains attributes. React Bootstrap Dark DropDowns variant : It is used when we are implementing dark navbar.menuVariant: It is
2 min read
React-Bootstrap Dropdowns Sizing React-Bootstrap Dropdowns are used to display content when users click or hover on them. React Bootstrap Dropdown sizing is set to fix the width of Dropdown so that it should be responsive for all screens. React-Bootstrap Dropdowns Sizing Used classes:large: This class is used to create dropdowns wi
2 min read
Bootstrap 5 Dropdowns Events In this article, we will learn about the Bootstrap 5 Dropdowns events fired when interacting with the Bootstrap 5 dropdown. For example, these events are fired when an off-canvas element is toggled to be visible or hidden.Bootstrap 5 dropdowns are dropdown overlay menus that can be used to display a
2 min read
Bootstrap 4 | Dropdowns Dropdowns are one of the most important parts of an interactive website. A dropdown menu is the collection of menu items that allow users to choose a value from the list. The .dropdown class is used to design the drop-down menu. Example: HTML <!DOCTYPE html> <html lang="en">
8 min read
Bootstrap 5 Dropdowns Bootstrap 5 is the latest major release by Bootstrap in which they have revamped the UI and made various changes. Dropdowns are toggleable, contextual overlays for displaying lists of links and more. Theyâre made interactive with the included Bootstrap dropdown JavaScript plugin. Theyâre toggled by
9 min read
React-Bootstrap Dropdown Component React-Bootstrap is a front-end framework that was designed keeping react in mind. Dropdown Component provides a way to displaying lists of links or more actions within a menu when clicked over it. We can use the following approach in ReactJS to use the react-bootstrap Dropdown Component.Dropdown Pro
5 min read
Bootstrap 5 Dropdowns Methods In Bootstrap 5 Dropdowns, there are pre-defined methods that we can use to trigger different types of functionalities in dropdowns. The methods can be implemented using JavaScript and JQuery.Bootstrap 5 Dropdowns Methods: The Dropdowns Methods with their function are given below:toggle() method: Thi
4 min read
Bootstrap 5 Dropdowns Usage Bootstrap 5 dropdowns allow users to display a list of options that can be selected by clicking on a button or link. They are often used in navigation menus, form selectors, and other user interfaces. To use a dropdown in Bootstrap 5, you will need to include the Bootstrap CSS and JavaScript files i
6 min read