Examples
Practical examples. Live demos.
Pick an example to open it full screen, with the live preview and its source side by side.
Pick an example to open it full screen, with the live preview and its source side by side.
Rows are matched by identity. Check a row, then Reverse: the same <li> moves, checkbox and all.
import 'nuclo' const pool = ['Cherry', 'Date', 'Elderberry', 'Fig', 'Grape'] let next = 0 const fruits = [ { name: 'Apple', done: false }, { name: 'Banana', done: false }, ] function add() { fruits.push({ name: pool[next++ % pool.length], done: false }) update() } export const Fruits = () => div( button('Add', { onClick: add }), button('Reverse', { onClick: () => { fruits.reverse(); update() } }), button('Remove first', { onClick: () => { fruits.shift(); update() } }), ul( list(() => fruits, (fruit) => li( label( input({ type: 'checkbox', checked: () => fruit.done, onChange: () => { fruit.done = !fruit.done; update() }, }), span( { className: () => (fruit.done ? 'done' : '') }, () => fruit.name, ), ), ), ), ), )