Wrap an initial value in $state to make it reactive. Read and write it like a regular variable.
Call the onadd callback with the new todo, then clear the input.
Use bind:value to keep the input and task in sync.
<script>
let { onadd } = $props();
let task = $state('');
function submit(event) {
event.preventDefault();
onadd({ task, completed: false });
task = '';
}
</script>
<form onsubmit={submit}>
<label>
Task
<input type="text" bind:value={task} required>
</label>
<button>Add</button>
</form>