3. Properties and events
The browser stores text typed into an <input>. To keep component state and the field in sync, connect them in both directions:
HE.onValueInput SetNameproduces aSetNameaction containing the current text.handleActionsaves it in state.HP.value state.namesets the displayed value from state. WhenSubmitclearsname, the field clears too.
In a field the reader types text into (a text input like this one, or a textarea), a render writes value only when it differs from the value rendered last, so a render that comes before the action of a key leaves the key, and the caret, where the reader put them. A component that refuses an edit while keeping the same name therefore leaves the edit in the field: to take it out, render a different value or set the element's value yourself. Other controls, such as a select or a range, are different: the page can change what they show without the reader typing, so their rendered value is compared with the element on every render.
HP is Halogen.HTML.Properties. It provides HP.value, HP.placeholder, HP.type_ and HP.checked. Input types such as InputCheckbox and button types such as ButtonSubmit come from DOM.HTML.Indexed.
Checkboxes use HP.checked and HE.onChecked, which supplies a Bool. Properties are checked against the element type: HP.checked on a button does not compile. Reading records with state.name requires OverloadedRecordDot.
Submitting
Pressing Enter in the field or clicking a ButtonSubmit button submits the form. HE.onSubmit converts that event into Submit.
The browser would normally submit the form and navigate, reloading this page. Wrap the handler in HE.preventingDefault to prevent that behaviour.
Calling preventDefault from Web.Event.Event through H.sync inside an action depends on the action running before browser dispatch ends. If the action is queued, it may be too late. HE.preventingDefault acts in the event listener before handing the action to Halogen, so it also works when the component is busy.
Exercise
Add submitted :: [Text] to State, initially []. Make Submit append the current name, using T.toUpper when Shout is checked. Import Data.Text qualified as T.
Display submitted names below the form in an HH.ul_. Build its children with [HH.li_ [HH.text item] | item <- state.submitted].