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
Two Counters + Sum
A--
A++
A =
B--
B++
B =
Sum =
PHP
📄 Copy code
<?php $a = state(0); $b = state(0); $app = div( [ cls('container') ], [ h2([], [ text('Two Counters + Sum') ]), div( [ cls('my-2') ], [ div( [ cls('btn-group ') ], [ button([ cls('btn btn-primary'), on('click', inc($a, -1))], [ text('A--') ]), button([cls('btn btn-primary'), on('click', inc($a, 1))], [ text('A++') ]), ]), span([], [ text(concat(' A = ', read($a))) ]) ]), div( [ cls('my-2') ], [ div( [ cls('btn-group ') ], [ button([ cls('btn btn-primary'), on('click', inc($b, -1)) ], [ text('B--') ]), button([ cls('btn btn-primary'), on('click', inc($b, 1)) ], [ text('B++') ]), ]), span([], [ text(concat(' B = ', read($b))) ]) ]), h3([], [ text(concat('Sum = ', add($a, read($b)))) ]), ]);