How to Make Scrollable Drop Down Lists in React-Bootstrap ?
Last Updated :
24 Apr, 2025
In this article, we will learn how to make Scrollable Dropdown lists in React-Bootstrap. Drop-down lists allow users to choose an option from a list of available options visible whenever the corresponding component is clicked or triggered. Using React-bootstrap, we can customize the drop-down list as needed.
Syntax:
<Dropdown>
<Dropdown.Toggle>...</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item>
<Dropdown.Item>
</Dropdown.Item>
</Dropdown.menu>
</Dropdown>
Steps to create the application:
Step 1: Create the react app using the following CRA command.
npx create-react-app appdemo
Step 2: Now, navigate to your current project i.e. appdemo using the following command.
cd appdemo
Step 3: Install the required modules i.e. react-bootstrap and bootstrap using the following command
npm install react-bootstrap bootstrap
Step 4: Import the necessary components from react-bootstrap as per requirement. To demonstrate a scrollable dropdown list. I am importing Bootstrap CSS and Dropdown components from react-bootstrap.
import React from "react";
import Dropdown from "react-bootstrap/Dropdown";
Project Structure:
The project structure look like the following
Project Structurepackage.json:
{
"name": "appdemo",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.3.2",
"react": "^18.2.0",
"react-bootstrap": "^2.8.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
}
Approach
We will use react-bootstrap dropdown component to create the scrollable dropdown list as shown below.
Example: Let us create a dropdown list component using React-bootstrap
JavaScript
// App.js
import React from 'react';
import ScrollableDropdown from './ScrollableDropdown';
import './App.css';
const App = () => {
return (
<div class="component">
<ScrollableDropdown />
</div>
);
};
export default App;
JavaScript
// ScrollableDropdown.jsx
import React from "react";
import Dropdown from "react-bootstrap/Dropdown";
import "./ScrollableDropdown.css";
const ScrollableDropdown = () => {
return (
<Dropdown>
<h4 class="subtitle">
What is your specialization?
</h4>
<Dropdown.Toggle
variant="success"
id="dropdown-basic"
>
select from here
</Dropdown.Toggle>
<Dropdown.Menu
style={{
maxHeight: "200px",
overflowY: "auto",
}}>
<Dropdown.Item href="#">CSE</Dropdown.Item>
<Dropdown.Item href="#">IT</Dropdown.Item>
<Dropdown.Item href="#">
AI & DS
</Dropdown.Item>
<Dropdown.Item href="#">
AI & ML
</Dropdown.Item>
<Dropdown.Item href="#">EEE</Dropdown.Item>
<Dropdown.Item href="#">ECE</Dropdown.Item>
<Dropdown.Item href="#">
CIVIL
</Dropdown.Item>
<Dropdown.Item href="#">MECH</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
);
};
export default ScrollableDropdown;
JavaScript
// index.js
import React from 'react';
import ReactDOM from 'react-dom';
import 'bootstrap/dist/css/bootstrap.min.css';
import App from './App';
ReactDOM.render(<App />, document.getElementById('root'));
CSS
/* ScrollableDropdown.css*/
.subtitle{
margin-bottom:30px
}
CSS
/* App.css */
.component {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
Explanation: In the above code, we created a functional component called ScrollableDropdown in which we are using the Dropdown component which is imported from React-bootstrap.
The Dropdown component comprises of various other components as follows:
- Dropdown.Toggle: This is used to trigger the element for dropdown containing the text "select from here".
- Dropdowm.Menu: This is used to display the dropdown menu and styled to make the dropdown menu scrollable with
- Dropdown.Item: This is included in the Dropdown.Menu and used to represent the individual options/choices in the dropdown list to choose.
- We can add more customization to our component using CSS.
Steps to run the application:
To start the application. use the commands:
npm start
Output:
Output
Similar Reads
How to make horizontal scrollable in a bootstrap row?
Here is the task to make horizontally scrollable in a bootstrap row. It can be done by the following approach: Approach: Making all the div element in inline using display: inline-block; propertyAdding the scroll bar to all the div element using overflow-x: auto; property.white-space: nowrap; proper
1 min read
How to make Draggable and Scrollable Modal in Bootstrap?
Given an HTML document and the task is to create a bootstrap modal that can be scrolled and dragged on a mobile device. This task can be easily achieved using the "Scrolling long content" models available in the Bootstrap library.Approach: Modals are built with HTML, CSS, and JavaScript. They are po
2 min read
How to make vertical scrollable rows in bootstrap?
In Bootstrap, creating vertically scrollable rows allows for efficient display of large content within a limited space. By enabling vertical scrolling, users can view content that exceeds the visible area without altering the overall page layout, improving usability.It can be done by the following a
2 min read
How to use Multi-Select Dropdown in React-Bootstrap ?
In ReactJS applications, we always need to add the UI component that allows us to select multiple options from the DropDown list. So in Bootstrap, the Multi-Select Dropdown is a UI component that allows us to select multiple different options from the list of dropdown menus. Additionally, we can do
4 min read
How to add scroll into react-bootstrap Modal Body?
React Bootstrap provides a straightforward way to create modal dialogue the for your web applications. However, sometimes the content within the modal body can be too long to fit within modal's default height. In such cases, you might add a scrollbar to the modal body to ensure users can scroll thro
2 min read
How to Create Smaller `Input` in React-Bootstrap ?
ReactJS is one of the most favorite libraries for building attractive applications. Combining Bootstrap with ReactJS is a powerful tool for making the application more interactive. A Smaller Input in React-Bootstrap refers to reducing the size of an input field component, typically achieved by apply
4 min read
How To Install Bootstrap in ReactJS?
Bootstrap is one of the most popular CSS frameworks for developing responsive and mobile-first websites. Integrating Bootstrap with ReactJS helps you build sleek, responsive interfaces quickly and easily. In this article, we will walk you through the step-by-step process of installing Bootstrap in R
4 min read
How to Add a Image to React Bootstrap dropdown ?
In this article, we will see how to add an image to the React Bootstrap dropdown. It is a React-based implementation of the Bootstrap components. Dropdown Component provides a way to display lists of links or more actions within a menu when clicked over it. Steps to Create React Application and Inst
3 min read
How to Add Headers inside the Dropdown Menu in Bootstrap ?
Bootstrap provides the ability to create headers within dropdown menus, which enhances the clarity and organization of your website's navigation. Headers serve as titles or categories that group related dropdown items together, making it easier for users to quickly locate what they are looking for a
2 min read
How to Add Headers inside the Dropdown Menu in Bootstrap ?
Drop-down menus are a common element used in web development to provide users with a list of options. Adding headers inside a drop-down menu can improve its organization and usability. This means to add headers inside the dropdown menu, use the .dropdown-header class in Bootstrap. Table of Content U
3 min read