brumate/ui

State

A part with state has one prop for it, such as isSelected of a Checkbox or value of a TextField. How you pass it picks who keeps the state.

<!-- The part keeps its own state, which starts off. -->
<Checkbox>Subscribe</Checkbox>

<!-- The part keeps its own copy, which starts on. A new value from you replaces it. -->
<Checkbox isSelected>Subscribe</Checkbox>

<!-- The part writes your signal. -->
<Checkbox isSelected=$bind(subscribed)>Subscribe</Checkbox>

<!-- The part asks you. It shows what you keep. -->
<Checkbox isSelected=$bind(subscribed, (next) => { if (!locked) subscribed = next; })>Subscribe</Checkbox>

There is no defaultSelected or defaultValue: a let prop of brumate already does both. See Props that the component writes.

State Parts
isSelected ToggleButton, Checkbox, Switch
value TextField, SearchField, CheckboxGroup, RadioGroup
selectedKeys ToggleButtonGroup