How to use HTML <select> tag in ReactJS ? Last Updated : 16 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report HTML <select> tag in react is a common web development component used for dynamic form input or as a select menu. It provides multiple selection options in the form of a dropdown menu. It enables the web page to render a select box with the options. The <select> tag is used as an outer element and the <option> element is nested within the <select> tag for defining options in a list.How to use Select tag in React ?To use the select tag in React we will use HTML Select and create an array for the drop-down options. Use the HTML Select tag and inside iterate the array elements using array map to render the items as options. On the <select> tag, we will use the "onChange" property which will hold a reference to the "onOptionChangeHandler" function. This function will get triggered whenever we change the value of the dropdown.Steps to create the applicationStep 1: Create a React.js application using the following command:npx create-react-app foldernameStep 2: After creating your project folder i.e. folder name, move into that directory using the following command:cd foldernameProject StructureExample: In this example we will create a dropdown selection input with some options present in the given options array. CSS /* App.css */ .App { text-align: center; } .geeks { color: green; } JavaScript // App.js import React, { useState } from "react"; import "./App.css"; const App = () => { const [data, setData] = useState(undefined); const options = [ "HTML", "CSS", "JavaScript", "React", "Redux", ]; const onOptionChangeHandler = (event) => { setData(event.target.value); console.log( "User Selected Value - ", event.target.value ); }; return ( <center> <h1 className="geeks"> GeeksforGeeks</h1> <h3>HTML select tag in React js</h3> <select onChange={onOptionChangeHandler}> <option>Please choose one option</option> {options.map((option, index) => { return ( <option key={index}> {option} </option> ); })} </select> <h3>You selected: {data} </h3> </center> ); }; export default App; Step to Run Application: To run the application, execute the below command from the root directory of the project:npm startOutput: Your web application will be live on “http://localhost:3000”. Now click on the dropdown to select any value. Comment More infoAdvertise with us Next Article How to use HTML <select> tag in ReactJS ? K kartikmukati Follow Improve Article Tags : Misc Web Technologies ReactJS HTML-Tags React-Questions +1 More Practice Tags : Misc Similar Reads How To Set Default Value In Select using ReactJS? When building forms in ReactJS, it is common to work with select dropdowns where users can choose an option from a list. Sometimes, you may want to set a default value in the select dropdown to pre-select an option when the form loads. In this article, weâll explore different approaches to set a def 3 min read How to Use react-select in React Application? React Select is a flexible and handy dropdown library for React that handles multi-select, loading data asynchronously, custom options, and more in your components with ease. In this article, we will see how to use react-select in React Application. PrerequisiteNode.js installednpm or yarn package m 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 use Tailwind Forms Plugin with React Select ? Tailwind CSS, a utility-first styling library for web design, offers Tailwind forms as plugins that provide a foundational reset for form styles. This simplifies the styling process for form elements, allowing easy customization with utilities. React Select, a select component library, is employed f 4 min read How to put ReactJS component inside HTML string ? Putting the React JS component inside the HTML library is not recommended and may lead to conflict in React lifecycle methods. But it can be done by parsing the HTML String into DOM using the html-to-react module. html-to-react is a lightweight library that is responsible for converting raw HTML to 3 min read Like