How to use HTML <select> tag in ReactJS ? Last Updated : 16 Sep, 2024 Comments Improve Suggest changes 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 ? 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 How to Disable Text Selection in ReactJS ? In this article, we will see how to disable the text selection in ReactJS. Prerequisites:Introduction to ReactReact HooksNPM or NPXWeb applications ofteÂn provide a valuable feature called text seleÂction, enabling users to easily highlight and copy content from a webpage. However, there are situat 4 min read How to Set Selected Option of a Select in React? In the React setting the selected option of a Select can be achieved using different approaches including using the native HTML <select> element and using third-party select components like react-select. We will discuss two approaches to Setting selected options of a select in React: Table of 3 min read How to use Select Component in Material UI ? Select components are used for collecting user-provided information from a list of options. Material UI for React has this component available for us and it is very easy to integrate. We can use the Select Component in ReactJS using the following approach:Creating React Application And Installing Mo 2 min read How To Get Select Element's Value In react-bootstrap? React-Bootstrap is a popular library that provides Bootstrap-styled React components. One of the most commonly used form elements is the <select> dropdown, which allows users to choose from a list of options. In this article, weâll explore how to get the value of a select element in a React-Bo 2 min read How To Use ComboBox in ReactJS? When developing React applications, creating user-friendly forms with dropdowns or select inputs is common. However, sometimes you need more than just a static dropdown listâyou need a ComboBox. A ComboBox combines the functionality of a dropdown and an input field, allowing users to either select f 2 min read Like