Todo List (Refs + List Rendering)

easy
By FrontendAtlas Editorial · Updated Nov 12, 2026
easy level
Vue 3 Composition API with refs and computedList rendering with v-for and keysArray updates with map and filter (in-place changes are tracked too)Basic component-level state management
Build a small Todo List in Vue 3 using the Composition API and <script setup>. Users should be able to add tasks, mark them as completed, remove individual tasks, and clear all completed tasks. Framework focus: Vue SFC patterns, ref/reactive state, computed/watch, and v-model bindings.

Requirements

  • Render a Todo List as the main UI in App.vue.
  • Use a text input and 'Add' button to create new todos.
  • Display todos in a list using v-for.
  • Each todo should have a checkbox to toggle completion and a 'Remove' button.
  • Provide a 'Clear completed' button that removes all completed todos when clicked.

What the checks look for

The checks find elements by listitem, textbox, button "Add", checkbox, button "Remove", button "Clear completed", text "No tasks yet. Add your first one above.". Keep these in your markup.

Expected behavior

  • Clicking 'Add' with non-empty trimmed text adds a new todo to the list and clears the input.
  • Checking a todo's checkbox toggles its completed state and visually marks it (line-through).
  • Clicking 'Remove' deletes that specific todo.
  • Clicking 'Clear completed' removes all todos where done === true.
  • An empty state message is shown when there are no todos.

Implementation notes

  • Use ref('') for the controlled input value (newTask).
  • Store the list of todos in a ref<Todo[]>([]) where each todo has id, text, and done.
  • Use computed for simple derived state like hasTodos.
  • Implement helpers addTask, toggleTask, removeTask, and clearCompleted inside <script setup>.
  • Keep everything in a single App.vue component.

Solution idea

Use a single Vue 3 SFC with <script setup> to manage the todo list. Track the input value in newTask and store todos in a ref array with { id, text, done }. A computed property hasTodos drives the empty state and footer visibility. Actions (addTask, toggleTask, removeTask, clearCompleted) update the todos array, and the template uses v-for to render items plus a checkbox and Remove button.