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

Function HTMLFormExample

apps/docs/src/examples/color-area.tsx:83–125  ·  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 <ColorArea
102 class={style.ColorAreaRoot}
103 defaultValue={parseColor("rgb(100, 149, 237)")}
104 xName="red"
105 yName="green"
106 >
107 <ColorArea.Label class={style.ColorAreaLabel}>Label</ColorArea.Label>
108 <ColorArea.Background class={style.ColorAreaBackground}>
109 <ColorArea.Thumb class={style.ColorAreaThumb}>
110 <ColorArea.HiddenInputX />
111 <ColorArea.HiddenInputY />
112 </ColorArea.Thumb>
113 </ColorArea.Background>
114 </ColorArea>
115 <div class="flex space-x-2">
116 <button type="reset" class="kb-button">
117 Reset
118 </button>
119 <button type="submit" class="kb-button-primary">
120 Submit
121 </button>
122 </div>
123 </form>
124 );
125}

Callers

nothing calls this directly

Calls 1

parseColorFunction · 0.90

Tested by

no test coverage detected