MCPcopy Create free account
hub / github.com/kobaltedev/kobalte / HTMLFormExample

Function HTMLFormExample

apps/docs/src/examples/text-field.tsx:105–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

103}
104
105export function HTMLFormExample() {
106 let formRef: HTMLFormElement | undefined;
107
108 const onSubmit = (e: SubmitEvent) => {
109 e.preventDefault();
110 e.stopPropagation();
111
112 const formData = new FormData(formRef);
113
114 alert(JSON.stringify(Object.fromEntries(formData), null, 2));
115 };
116
117 return (
118 <form
119 ref={formRef}
120 onSubmit={onSubmit}
121 class="flex flex-col items-center space-y-6"
122 >
123 <TextField class={style["text-field"]} name="favorite-fruit">
124 <TextField.Label class={style["text-field__label"]}>
125 Favorite fruit
126 </TextField.Label>
127 <TextField.Input class={style["text-field__input"]} />
128 </TextField>
129 <div class="flex space-x-2">
130 <button type="reset" class="kb-button">
131 Reset
132 </button>
133 <button type="submit" class="kb-button-primary">
134 Submit
135 </button>
136 </div>
137 </form>
138 );
139}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected