Build the state
Declare title and tasks as state. Keep task creation local first; persistence can be added later with an explicit API.
#[State] private string $draft = '';
#[State] private array $tasks = [];
TextField()->value($this->state('draft'));
Button('Add')->onClick(function (): void {
if (trim($this->draft) !== '') {
$this->tasks[] = ['title' => $this->draft];
$this->draft = '';
}
});Compose the body
Render the title, bound field, add button, and task list. Use semantic headings and labels rather than anonymous containers everywhere.
Verify the behavior
Run aml test, use keyboard-only navigation, enter several tasks, and confirm state changes without a page reload or repeated HTTP request.
SUMMARY
What to remember
- View describes interfaces with typed PHP objects.
- Engine runs supported frontend behavior locally.
- State properties remain natural to read and modify.
- Components, layouts, routes, and styles keep large interfaces organized.