Appearance
Inputs and forms
Most form elements (unless noted) work just like normal input elements.
Custom Element
You may set initial value via either
valueattribute or proprertyhtml<!-- via attribute --> <phi-input value="initial value" />html<!-- via property (with Vue.js) --> <phi-input :value="'initial value'" />You may get current value from
valuepropertyjsconst alertValue = () => alert(input.value);You may update input value via
valuepropertyjsconst resetValue = () => input.value = "";Once you update
valueproperty from outside, settingvalueattribute no longer updatesvalueproperty value.You may subscribe
inputevent to watch user inputhtml<phi-input oninput="handleInput" />jsinput.addEventListener("input", handleInput);You may put
nameattribute to integrate with the enclosing<form>elementhtml<form method="POST"> <phi-input name="field_name" /> <input type="submit" value="Send" /> </form>Note that non-string values are serialized as follows on submit.
JS value type Form value null""(empty string)boolean1or0numbernumber.toString()arraycomma-separated string objectFormData
as Preact component
Use
valueprop to set value, andonChangeto subscribe changes as usualjsconst Demo = () => { const [value, setValue] = useState(""); return <Input value={ value } onChange={ setValue } />; };