36 lines
925 B
React
36 lines
925 B
React
import { Tooltip as ChakraTooltip, Portal } from '@chakra-ui/react'
|
|
import * as React from 'react'
|
|
|
|
export const Tooltip = React.forwardRef(function Tooltip(props, ref) {
|
|
const {
|
|
showArrow,
|
|
children,
|
|
disabled,
|
|
portalled = true,
|
|
content,
|
|
contentProps,
|
|
portalRef,
|
|
...rest
|
|
} = props
|
|
|
|
if (disabled) return children
|
|
|
|
return (
|
|
<ChakraTooltip.Root {...rest}>
|
|
<ChakraTooltip.Trigger asChild>{children}</ChakraTooltip.Trigger>
|
|
<Portal disabled={!portalled} container={portalRef}>
|
|
<ChakraTooltip.Positioner>
|
|
<ChakraTooltip.Content ref={ref} {...contentProps}>
|
|
{showArrow && (
|
|
<ChakraTooltip.Arrow>
|
|
<ChakraTooltip.ArrowTip />
|
|
</ChakraTooltip.Arrow>
|
|
)}
|
|
{content}
|
|
</ChakraTooltip.Content>
|
|
</ChakraTooltip.Positioner>
|
|
</Portal>
|
|
</ChakraTooltip.Root>
|
|
)
|
|
})
|