This is a simple dropdown component built using React. The dropdown displays a list of options when hovering over the button and closes the dropdown when an option is clicked.
To use the dropdown component in your React application, follow these steps:
First, make sure you have a React project set up. If not, you can create one using Create React App or any other method.
-
Clone or download this repository.
-
Copy the
Dropdown.js
component into your project.
The Dropdown
component accepts a single prop:
items
(Array): An array of items to display in the dropdown list.
import React from 'react';
import Dropdown from './Dropdown';
const options = ['Option 1', 'Option 2', 'Option 3'];
function App() {
return (
<div className="App">
<h1>Simple Dropdown Example</h1>
<Dropdown items={options} />
</div>
);
}
export default App;