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

Function PopoverTrigger

starters/hooks/src/Popover.tsx:51–72  ·  view source on GitHub ↗
({label, children, ...props}: PopoverTriggerProps)

Source from the content-addressed store, hash-verified

49}
50
51export function PopoverTrigger({label, children, ...props}: PopoverTriggerProps) {
52 let triggerRef = useRef<HTMLButtonElement>(null);
53 let state = useOverlayTriggerState(props);
54 let {triggerProps, overlayProps} = useOverlayTrigger({type: 'dialog'}, state, triggerRef);
55
56 return (
57 <>
58 <Button
59 {...triggerProps}
60 ref={triggerRef}
61 className="react-aria-Button button-base"
62 data-variant="primary">
63 {label}
64 </Button>
65 {state.isOpen && (
66 <Popover {...props} triggerRef={triggerRef} state={state}>
67 {cloneElement(children, overlayProps)}
68 </Popover>
69 )}
70 </>
71 );
72}

Callers

nothing calls this directly

Calls 2

useOverlayTriggerStateFunction · 0.90
useOverlayTriggerFunction · 0.90

Tested by

no test coverage detected