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

Function ErrorMessageExample

apps/docs/src/examples/select.tsx:145–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143}
144
145export function ErrorMessageExample() {
146 const [value, setValue] = createSignal("Grapes");
147
148 return (
149 <Select
150 value={value()}
151 onChange={setValue}
152 validationState={value() !== "Apple" ? "invalid" : "valid"}
153 options={STRING_OPTIONS}
154 placeholder="Select a fruit…"
155 itemComponent={(props) => (
156 <Select.Item item={props.item} class={style.select__item}>
157 <Select.ItemLabel>{props.item.rawValue}</Select.ItemLabel>
158 <Select.ItemIndicator class={style["select__item-indicator"]}>
159 <CheckIcon />
160 </Select.ItemIndicator>
161 </Select.Item>
162 )}
163 >
164 <Select.Trigger class={style.select__trigger} aria-label="Fruit">
165 <Select.Value<string> class={style.select__value}>
166 {(state) => state.selectedOption()}
167 </Select.Value>
168 <Select.Icon class={style.select__icon}>
169 <CaretSortIcon />
170 </Select.Icon>
171 </Select.Trigger>
172 <Select.ErrorMessage class={style["select__error-message"]}>
173 Hmm, I prefer apples.
174 </Select.ErrorMessage>
175 <Select.Portal>
176 <Select.Content class={style.select__content}>
177 <Select.Listbox class={style.select__listbox} />
178 </Select.Content>
179 </Select.Portal>
180 </Select>
181 );
182}
183
184export function HTMLFormExample() {
185 let formRef: HTMLFormElement | undefined;

Callers

nothing calls this directly

Calls 1

valueFunction · 0.50

Tested by

no test coverage detected