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

Function HTMLFormExample

apps/docs/src/examples/color-field.tsx:83–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81}
82
83export function HTMLFormExample() {
84 let formRef: HTMLFormElement | undefined;
85
86 const onSubmit = (e: SubmitEvent) => {
87 e.preventDefault();
88 e.stopPropagation();
89
90 const formData = new FormData(formRef);
91
92 alert(JSON.stringify(Object.fromEntries(formData), null, 2));
93 };
94
95 return (
96 <form
97 ref={formRef}
98 onSubmit={onSubmit}
99 class="flex flex-col items-center space-y-6"
100 >
101 <ColorField class={style["color-field"]} name="favorite-color">
102 <ColorField.Label class={style["color-field__label"]}>
103 Favorite hex color
104 </ColorField.Label>
105 <ColorField.Input class={style["color-field__input"]} />
106 </ColorField>
107 <div class="flex space-x-2">
108 <button type="reset" class="kb-button">
109 Reset
110 </button>
111 <button type="submit" class="kb-button-primary">
112 Submit
113 </button>
114 </div>
115 </form>
116 );
117}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected