MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ComboBox

Function ComboBox

starters/tailwind/src/ComboBox.tsx:29–68  ·  view source on GitHub ↗
({
  label,
  description,
  errorMessage,
  children,
  items,
  ...props
}: ComboBoxProps<T, M>)

Source from the content-addressed store, hash-verified

27}
28
29export function ComboBox<T, M extends 'single' | 'multiple' = 'single'>({
30 label,
31 description,
32 errorMessage,
33 children,
34 items,
35 ...props
36}: ComboBoxProps<T, M>) {
37 return (
38 <AriaComboBox
39 {...props}
40 className={composeTailwindRenderProps(
41 props.className,
42 'group flex flex-col gap-1 font-sans'
43 )}>
44 <Label>{label}</Label>
45 <FieldGroup>
46 <Input className="ps-3 pe-1" />
47 <FieldButton className="w-6 mr-1 outline-offset-0">
48 <ChevronDown aria-hidden className="w-4 h-4" />
49 </FieldButton>
50 </FieldGroup>
51 {props.selectionMode === 'multiple' && (
52 <ComboBoxValue
53 placeholder="No items selected"
54 className="text-xs text-neutral-600 dark:text-neutral-300"
55 />
56 )}
57 {description && <Description>{description}</Description>}
58 <FieldError>{errorMessage}</FieldError>
59 <Popover className="w-(--trigger-width)">
60 <ListBox
61 items={items}
62 className="outline-0 p-1 box-border max-h-[inherit] overflow-auto [clip-path:inset(0_0_0_0_round_.75rem)]">
63 {children}
64 </ListBox>
65 </Popover>
66 </AriaComboBox>
67 );
68}
69
70export function ComboBoxItem(props: ListBoxItemProps) {
71 return <DropdownItem {...props} />;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected