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() { const [selectedColor, setSelectedColor] = useState("#4c3434"); // Set initial color value const handleColorChange = (event) => { setSelectedColor(event.target.value); // Update the selected color value }; return ( <div className="container"> <h3>React Js get selected color value from a color picker</h3> <input type="color" value={selectedColor} onChange={handleColorChange} className="color-picker" /> <div style={{ marginTop: "10px" }}> Selected Color:{" "} <span style={{ color: selectedColor }} className="selected-value"> {selectedColor} </span> </div> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 500px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .color-picker { width: 200px; height: 30px; border-radius: 5px; } .selected-value { font-weight: bold; } </style> </body> </html>