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 [dates, setDates] = useState([]); const handleDateChange = (e) => { const selectedDate = e.target.value; setDates([...dates, selectedDate]); }; const handleChipRemove = (index) => { const newDates = [...dates]; newDates.splice(index, 1); setDates(newDates); }; return ( <div className='container'> <h3>React Js Select Multiple Date </h3> <p>Select a date:</p> <input type="date" onChange={handleDateChange} className="custom-date-input" /> <div className="date-chips"> {dates.map((date, index) => ( <div className="date-chip" key={index}> {date} <button className="close-button" onClick={() => handleChipRemove(index)}>X</button> </div> ))} </div> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { text-align: center; margin: 20px; width: 400px; margin: 0 auto; } p { margin-bottom: 10px; } .custom-date-input { /* Your styling goes here */ width: 200px; /* Adjust width as needed */ padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; } /* Date Chips */ .date-chips { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; margin-top: 20px; } .date-chip { background-color: #333; color: #fff; padding: 0.5em 1em; margin: 0.5em; border-radius: 1em; font-size: 14px; } .close-button { background: none; border: none; color: white; font-size: 14px; cursor: pointer; margin-left: 0.5em; } </style> </body> </html>