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://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; const App = () => { const options = ['React', 'Vue', 'Angular', 'Node', 'Express', 'Bootstrap', 'MongoDb', 'Javascript', 'Vuetify']; const [search, setSearch] = useState(''); const [selectedOption, setSelectedOption] = useState(''); const filteredOptions = options.filter(option => option.toLowerCase().includes(search.toLowerCase())); const handleSearchChange = event => { setSearch(event.target.value); }; const handleOptionChange = event => { setSelectedOption(event.target.value); }; return ( <div className="container"> <h3>React Js Search/Filter Dropdown</h3> <input className="search-input" type="text" value={search} onChange={handleSearchChange} placeholder="Search" /><br /> <select className="custom-dropdown" value={selectedOption} onChange={handleOptionChange} size={filteredOptions.length} > <option disabled value="">Please select one</option> {filteredOptions.map(option => ( <option key={option} value={option}>{option}</option> ))} </select> <pre>Selected language: {selectedOption}</pre> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> h3 { margin-bottom: 10px; } .search-input { width: 250px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 10px; } .custom-dropdown { width: 250px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; background-color: #fff; color: #333; cursor: pointer; } pre { margin-top: 10px; font-size: 14px; } </style> </body> </html>