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

Function ComboBoxItem

packages/@react-spectrum/s2/src/ComboBox.tsx:469–535  ·  view source on GitHub ↗
(props: ComboBoxItemProps)

Source from the content-addressed store, hash-verified

467} as const;
468
469export function ComboBoxItem(props: ComboBoxItemProps): ReactNode {
470 let ref = useRef(null);
471 let isLink = props.href != null;
472 let {size} = useContext(InternalComboboxContext);
473 // oxlint-disable react/react-compiler
474 return (
475 <ListBoxItem
476 {...props}
477 ref={ref}
478 textValue={
479 props.textValue ||
480 (typeof props.children === 'string' ? (props.children as string) : undefined)
481 }
482 style={pressScale(ref, props.UNSAFE_style)}
483 className={renderProps =>
484 (props.UNSAFE_className || '') + listboxItem({...renderProps, size, isLink}, props.styles)
485 }>
486 {renderProps => {
487 let {children} = props;
488 return (
489 <>
490 <Provider
491 values={[
492 [
493 IconContext,
494 {
495 slots: {
496 icon: {
497 render: centerBaseline({slot: 'icon', styles: iconCenterWrapper}),
498 styles: icon
499 }
500 }
501 }
502 ],
503 [
504 AvatarContext,
505 {
506 slots: {
507 avatar: {size: avatarSize[size], styles: avatar}
508 }
509 }
510 ],
511 [
512 TextContext,
513 {
514 slots: {
515 label: {styles: label({size})},
516 description: {styles: description({...renderProps, size})}
517 }
518 }
519 ]
520 ]}>
521 {!isLink && !props.onAction && (
522 <CheckmarkIcon
523 size={checkmarkIconSize[size]}
524 className={checkmark({...renderProps, size})}
525 />
526 )}

Callers

nothing calls this directly

Calls 2

pressScaleFunction · 0.90
centerBaselineFunction · 0.90

Tested by

no test coverage detected