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

Function OptionGroupExample

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

Source from the content-addressed store, hash-verified

315];
316
317export function OptionGroupExample() {
318 return (
319 <Select<Food, Category>
320 options={GROUP_OBJECT_OPTIONS}
321 optionValue="value"
322 optionTextValue="label"
323 optionDisabled="disabled"
324 optionGroupChildren="options"
325 placeholder="Select a food…"
326 itemComponent={(props) => (
327 <Select.Item item={props.item} class={style.select__item}>
328 <Select.ItemLabel>{props.item.rawValue.label}</Select.ItemLabel>
329 <Select.ItemIndicator class={style["select__item-indicator"]}>
330 <CheckIcon />
331 </Select.ItemIndicator>
332 </Select.Item>
333 )}
334 sectionComponent={(props) => (
335 <Select.Section class={style.select__section}>
336 {props.section.rawValue.label}
337 </Select.Section>
338 )}
339 >
340 <Select.Trigger class={style.select__trigger} aria-label="Food">
341 <Select.Value<Food> class={style.select__value}>
342 {(state) => state.selectedOption().label}
343 </Select.Value>
344 <Select.Icon class={style.select__icon}>
345 <CaretSortIcon />
346 </Select.Icon>
347 </Select.Trigger>
348 <Select.Portal>
349 <Select.Content class={style.select__content}>
350 <Select.Listbox class={style.select__listbox} />
351 </Select.Content>
352 </Select.Portal>
353 </Select>
354 );
355}
356
357export function MultipleSelectionExample() {
358 const [values, setValues] = createSignal(["Blueberry", "Grapes"]);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected