MCPcopy Create free account
hub / github.com/editablejs/editable / Tooltip

Function Tooltip

packages/ui/src/tooltip.tsx:18–66  ·  view source on GitHub ↗
({
  children,
  side = 'bottom',
  align = 'center',
  arrow = true,
  arrowFill,
  content,
  defaultOpen = false,
  size = 'default',
  className,
  ...props
})

Source from the content-addressed store, hash-verified

16}
17
18export const Tooltip: React.FC<TooltipProps> = ({
19 children,
20 side = 'bottom',
21 align = 'center',
22 arrow = true,
23 arrowFill,
24 content,
25 defaultOpen = false,
26 size = 'default',
27 className,
28 ...props
29}) => {
30 const [trigger, setTrigger] = React.useState<HTMLDivElement | null>(null)
31 const [contentRef, setContent] = React.useState<HTMLDivElement | null>(null)
32
33 const [open = false, setOpen] = usePointerOpen({
34 triggerEl: trigger,
35 contentEl: contentRef,
36 defaultOpen: defaultOpen,
37 })
38
39 return (
40 <Popper>
41 <PopperAnchor ref={setTrigger}>{children}</PopperAnchor>
42 <Presence present={open}>
43 <DismissableLayer onPointerDownOutside={() => setOpen(false)}>
44 <Portal>
45 <PopperContent
46 ref={setContent}
47 side={side}
48 align={align}
49 css={[
50 tw`text-white bg-black bg-opacity-80 text-center rounded z-50`,
51 size === 'large' && tw`px-3 py-1.5 text-lg`,
52 size === 'small' && tw`px-1 py-0.5 text-xs`,
53 size === 'default' && tw`px-2 py-1 text-base`,
54 ]}
55 className={className}
56 {...props}
57 >
58 {content}
59 {arrow && <PopperArrow style={{ fill: arrowFill }} />}
60 </PopperContent>
61 </Portal>
62 </DismissableLayer>
63 </Presence>
64 </Popper>
65 )
66}

Callers

nothing calls this directly

Calls 2

usePointerOpenFunction · 0.90
setOpenFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…