screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/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; function App() { const [selectedMonth, setSelectedMonth] = useState(''); const [formattedMonth, setFormattedMonth] = useState(''); const handleMonthChange = (event) => { const selectedMonth = event.target.value; const [year, month] = selectedMonth.split('-'); const date = new Date(year, month - 1); const monthName = date.toLocaleString('default', { month: 'long' }); const formattedMonth = `${monthName} ${year}`; setFormattedMonth(formattedMonth); }; return ( <div className='container'> <h3>React Js Month Picker Example</h3> <div className="chips"> {formattedMonth && <div className="chip">{formattedMonth}</div>} </div> <input type="month" onChange={handleMonthChange} className='input-field' /> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 600px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; } .chip { display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; background-color: #00796B; border-radius: 16px; font-size: 14px; color: #fff; font-weight: bold; cursor: pointer; transition: background-color 0.3s; } .chip:hover { background-color: #d6d6d6; color:#000 } .input-field { padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 4px; outline-color: #B388FF; } </style> </body> </html>