// Copyright (c) Tailscale Inc & AUTHORS // SPDX-License-Identifier: BSD-3-Clause import * as PopoverPrimitive from "@radix-ui/react-popover" import cx from "classnames" import React, { ReactNode } from "react" type Props = { className?: string content: ReactNode children: ReactNode /** * asChild renders the trigger element without wrapping it in a button. Use * this when you want to use a `button` element as the trigger. */ asChild?: boolean /** * side is the side of the direction from the target element to render the * popover. */ side?: "top" | "bottom" | "left" | "right" /** * sideOffset is how far from a give side to render the popover. */ sideOffset?: number /** * align is how to align the popover with the target element. */ align?: "start" | "center" | "end" /** * alignOffset is how far off of the alignment point to render the popover. */ alignOffset?: number open?: boolean onOpenChange?: (open: boolean) => void } /** * Popover is a UI component that allows rendering unique controls in a floating * popover, attached to a trigger element. It appears on click and manages focus * on its own behalf. * * To use the Popover, pass the content as children, and give it a `trigger`: * * Open popover}> *

Hello world!

*
* * By default, the toggle is wrapped in an accessible } asChild> *

Hello world!

* * * The former style is recommended whenever possible. */ export default function Popover(props: Props) { const { children, className, content, side, sideOffset, align, alignOffset, asChild, open, onOpenChange, } = props return ( {children} {(portalContainer) => ( {content} )} ) } Popover.defaultProps = { sideOffset: 10, } const PortalContainerContext = React.createContext( undefined )