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

Function HTMLFormExample

apps/docs/src/examples/switch.tsx:90–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88}
89
90export function HTMLFormExample() {
91 let formRef: HTMLFormElement | undefined;
92
93 const onSubmit = (e: SubmitEvent) => {
94 e.preventDefault();
95 e.stopPropagation();
96
97 const formData = new FormData(formRef);
98
99 alert(JSON.stringify(Object.fromEntries(formData), null, 2));
100 };
101
102 return (
103 <form
104 ref={formRef}
105 onSubmit={onSubmit}
106 class="flex flex-col items-center space-y-6"
107 >
108 <Switch class={style.switch} name="airplane-mode" value="on">
109 <Switch.Label class={style.switch__label}>Airplane mode</Switch.Label>
110 <Switch.Input class={style.switch__input} />
111 <Switch.Control class={style.switch__control}>
112 <Switch.Thumb class={style.switch__thumb} />
113 </Switch.Control>
114 </Switch>
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

no outgoing calls

Tested by

no test coverage detected