Thorm
Get started
Get Started in 5 minutes
First Page
Your first page
The controller
Header
Hero section
Contact section
The API
Considerations
Docs
Overview
Guides
Intro
Atoms
Node builders
Props helpers
State + expressions
Expression builder
Events + actions
Effects + targets
API
Api
Examples
Roadmap
Blog
Community
Get Started
GitHub
Resettable Counter
Change the step size, increment, and reset to a fixed value.
Resettable Counter
Count: 42
Inc by input
Reset to 1000
PHP
📄 Copy code
<?php $count = state(42); $step = state(1); $increment = el('input', [ cls('form-control'), attrs(['type' => 'number', 'value' => read($step)]), on('input', set($step, num(ev('target.value')))), ]); $app = el('div', [cls('container')], [ el('h1', [cls('mt-5')], [ text('Resettable Counter') ]), el('h2', [], [ text(concat('Count: ', read($count))) ]), $increment, el('div', [cls('d-flex justify-content-around p-5')], [ el('button', [ cls('btn btn-primary'), on('click', add($count, read($step))) ], [ text('Inc by input') ]), el('button', [ cls('btn btn-danger'), on('click', set($count, 1000)) ], [ text('Reset to 1000') ]) ]), ]);