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

Function ErrorMessageExample

apps/docs/src/examples/combobox.tsx:158–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

156}
157
158export function ErrorMessageExample() {
159 const [value, setValue] = createSignal("Grapes");
160
161 const onInputChange = (value: string) => {
162 // Remove selection when input is cleared.
163 if (value === "") {
164 setValue("");
165 }
166 };
167
168 return (
169 <Combobox
170 options={ALL_STRING_OPTIONS}
171 value={value()}
172 onChange={setValue}
173 onInputChange={onInputChange}
174 validationState={value() !== "Apple" ? "invalid" : "valid"}
175 placeholder="Search a fruit…"
176 itemComponent={(props) => (
177 <Combobox.Item item={props.item} class={style.combobox__item}>
178 <Combobox.ItemLabel>{props.item.rawValue}</Combobox.ItemLabel>
179 <Combobox.ItemIndicator class={style["combobox__item-indicator"]}>
180 <CheckIcon />
181 </Combobox.ItemIndicator>
182 </Combobox.Item>
183 )}
184 >
185 <Combobox.Control class={style.combobox__control} aria-label="Fruit">
186 <Combobox.Input class={style.combobox__input} />
187 <Combobox.Trigger class={style.combobox__trigger}>
188 <Combobox.Icon class={style.combobox__icon}>
189 <CaretSortIcon />
190 </Combobox.Icon>
191 </Combobox.Trigger>
192 </Combobox.Control>
193 <Combobox.ErrorMessage class={style["combobox__error-message"]}>
194 Hmm, I prefer apples.
195 </Combobox.ErrorMessage>
196 <Combobox.Portal>
197 <Combobox.Content class={style.combobox__content}>
198 <Combobox.Listbox class={style.combobox__listbox} />
199 </Combobox.Content>
200 </Combobox.Portal>
201 </Combobox>
202 );
203}
204
205export function HTMLFormExample() {
206 let formRef: HTMLFormElement | undefined;

Callers

nothing calls this directly

Calls 1

valueFunction · 0.50

Tested by

no test coverage detected