screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { // Sample data - USA developer names const usaDevelopers = [ "John Smith", "Jane Doe", "David Johnson", "Emily Williams", // Add more names here ]; // State to hold the selected developer const [selectedDeveloper, setSelectedDeveloper] = useState(''); // Event handler for changing the selected developer const handleSelectChange = (event) => { setSelectedDeveloper(event.target.value); }; return ( <div className='container'> <h1 className='heading'>React Js Map Select Option | Dropdown</h1> <select className='select' value={selectedDeveloper} onChange={handleSelectChange} > <option value="" className='option'> Select a developer </option> {usaDevelopers.map((developer, index) => ( <option key={index} value={developer} className='option'> {developer} </option> ))} </select> <p className='selected-developer'> Selected Developer: {selectedDeveloper} </p> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { font-family: Arial, sans-serif; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); max-width: 600px; margin: 0 auto; text-align: center; } .heading { font-size: 24px; margin-bottom: 10px; color: #333; } .select { width: 100%; padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 4px; outline: none; } .option { font-size: 16px; } .selected-developer { margin-top: 10px; font-size: 18px; color: #007bff; /* Blue color for the selected developer text */ } </style> </body> </html>