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 [text, setText] = useState(""); const maxCharacterCount = 100; // Set your desired maximum character count const handleChange = (event) => { const inputText = event.target.value; if (inputText.length <= maxCharacterCount) { setText(inputText); } }; return ( <div className="container"> <h3>React Js Character Counter</h3> <textarea value={text} onChange={handleChange} placeholder="Type something..." rows={4} cols={50} /> <div className="result"> Characters left: {maxCharacterCount - text.length}/ {maxCharacterCount} </div> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> /* Assuming you are using React (as indicated by the className attribute) */ .container { max-width: 400px; margin: 0 auto; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); font-family: Arial, sans-serif; } /* CSS for the textarea */ .container textarea { width: 100%; padding: 10px; margin-bottom: 10px; resize: vertical; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; box-sizing: border-box; } /* CSS for the characters count */ .result { font-size: 12px; text-align: right; color: #666; } </style> </body> </html>