claude-sonnet-4-20250514-thinking-32k· Anthropic LMArena Human Preference 140K
create a todo list application
- User
create a todo list application
- Assistant
I'll create a complete todo list application using HTML, CSS, and JavaScript. Here's a fully functional app:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Todo List App</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; padding: 20px; } .container { max-width: 600px; margin: 0 auto; background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); overflow: hidden; } .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-align: center; padding: 30px 20px; } .header h1 { font-size: 2.5em; margin-bottom: 10px; } .header p { opacity: 0.9; font-size: 1.1em; } .input-section { padding: 30px; border-bottom: 1px solid #eee; } .input-container { display: flex; gap: 10px; } #todoInput { flex: 1; padding: 15px; border: 2px solid #ddd; border-radius: 8px; font-size: 16px; outline: none; transition: border-color 0.3s ease; } #todoInput:focus { border-color: #667eea; } #addBtn { padding: 15px 25px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; font-weight: 600; transition: transform 0.2s ease; } #addBtn:hover { transform: translateY(-2px); } .stats { padding: 20px 30px; background: #f8f9fa; display: flex; justify-content: space-between; font-size: 14px; color: #666; } .todo-list { padding: 0 30px 30px; } .todo-item { display: flex; align-items: center; padding: 15px; margin: 10px 0; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea; transition: all 0.3s ease; } .todo-item:hover { background: #e9ecef; transform: translateX(5px); } .todo-item.completed { opacity: 0.6; border-left-color: #28a745; } .todo-item.completed .todo-text { text-decoration: line-through; color: #666; } .todo-checkbox { margin-right: 15px; width: 20px; height: 20px; cursor: pointer; } .todo-text { flex: 1; font-size: 16px; color: #333; } .delete-btn { background: #dc3545; color: white; border: none; padding: 8px 12px; border-radius: 5px; cursor: pointer; font-size: 12px; transition: background 0.3s ease; } .delete-btn:hover { background: #c82333; } .empty-state { text-align: center; padding: 50px 20px; color: #666; } .empty-state img { width: 100px; opacity: 0.5; margin-bottom: 20px; } .filter-buttons { padding: 20px 30px; display: flex; gap: 10px; justify-content: center; border-top: 1px solid #eee; } .filter-btn { padding: 10px 20px; border: 2px solid #ddd; background: white; border-radius: 5px; cursor: pointer; transition: all 0.3s ease; } .filter-btn.active { background: #667eea; color: white; border-color: #667eea; } </style> </head> <body> <div class="container"> <div class="header"> <h1>📝 Todo List</h1> <p>Stay organized and get things done!</p> </div> <div class="input-section"> <div class="input-container"> <input type="text" id="todoInput" placeholder="Add a new task..." maxlength="100"> <button id="addBtn">Add Task</button> </div> </div> <div class="stats"> <span id="totalTasks">Total: 0</span> <span id="completedTasks">Completed: 0</span> <span id="pendingTasks">Pending: 0</span> </div> <div class="filter-buttons"> <button class="filter-btn active" data-filter="all">All</button> <button class="filter-btn" data-filter="pending">Pending</button> <button class="filter-btn" data-filter="completed">Completed</button> </div> <div class="todo-list" id="todoList"> <div class="empty-state"> <h3>No tasks yet!</h3> <p>Add a task above to get started.</p> </div> </div> </div> <script> class TodoApp { constructor() { this.todos = JSON.parse(localStorage.getItem('todos')) || []; this.currentFilter = 'all'; this.initializeEventListeners(); this.render(); } initializeEventListeners() { const todoInput = document.getElementById('todoInput'); const addBtn = document.getElementById('addBtn'); const filterButtons = document.querySelectorAll('.filter-btn'); addBtn.addEventListener('click', () => this.addTodo()); todoInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') this.addTodo(); }); filterButtons.forEach(btn => { btn.addEventListener('click', (e) => { this.setFilter(e.target.dataset.filter); }); }); } addTodo() { const input = document.getElementById('todoInput'); const text = input.value.trim(); if (text === '') { alert('Please enter a task!'); return; } const todo = { id: Date.now(), text: text, completed: false, createdAt: new Date().toLocaleString() }; this.todos.push(todo); input.value = ''; this.saveTodos(); this.render(); } toggleTodo(id) { this.todos = this.todos.map(todo => todo.id === id ? { ...todo, completed: !todo.completed } : todo ); this.saveTodos(); this.render(); } deleteTodo(id) { if (confirm('Are you sure you want to delete this task?')) { this.todos = this.todos.filter(todo => todo.id !== id); this.saveTodos(); this.render(); } } setFilter(filter) { this.currentFilter = filter; document.querySelectorAll('.filter-btn').forEach(btn => { btn.classList.remove('active'); }); document.querySelector(`[data-filter="${filter}"]`).classList.add('active'); this.render(); } getFilteredTodos() { switch (this.currentFilter) { case 'completed': return this.todos.filter(todo => todo.completed); case 'pending': return this.todos.filter(todo => !todo.completed); default: return this.todos; } } updateStats() { const total = this.todos.length; const completed = this.todos.filter(todo => todo.completed).length; const pending = total - completed; document.getElementById('totalTasks').textContent = `Total: ${total}`; document.getElementById('completedTasks').textContent = `Completed: ${completed}`; document.getElementById('pendingTasks').textContent = `Pending: ${pending}`; } render() { const todoList = document.getElementById('todoList'); const filteredTodos = this.getFilteredTodos(); if (filteredTodos.length === 0) { todoList.innerHTML = ` <div class="empty-state"> <h3>${this.todos.length === 0 ? 'No tasks yet!' : 'No tasks match your filter!'}</h3> <p>${this.todos.length === 0 ? 'Add a task above to get started.' : 'Try a different filter or add more tasks.'}</p> </div> `; } else { todoList.innerHTML = filteredTodos.map(todo => ` <div class="todo-item ${todo.completed ? 'completed' : ''}"> <input type="checkbox" class="todo-checkbox" ${todo.completed ? 'checked' : ''} onchange="app.toggleTodo(${todo.id})"> <span class="todo-text">${todo.text}</span> <button class="delete-btn" onclick="app.deleteTodo(${todo.id})">Delete</button> </div> `).join(''); } this.updateStats(); } saveTodos() { localStorage.setItem('todos', JSON.stringify(this.todos)); } } // Initialize the app const app = new TodoApp(); </script> </body> </html>This todo list application includes:
Core Features:
- Add new tasks by typing and clicking "Add Task" or pressing Enter
- Mark tasks as complete/incomplete with checkboxes
- Delete tasks with confirmation
- Persistent storage using localStorage (tasks remain after page refresh)
Advanced Features:
- Filter tasks by All, Pending, or Completed
- Task statistics showing total, completed, and pending counts
- Responsive design that works on desktop and mobile
- Smooth animations and hover effects
- Empty state messages for better user experience
How to use:
- Save the code as an HTML file (e.g.,
todo.html) - Open it in any web browser
- Start adding tasks and managing your todo list!
The app automatically saves your tasks locally, so they'll persist between browser sessions. The interface is clean, modern, and intuitive to use.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.