Overlays
Popover
Non-modal floating panel anchored to a trigger, with optional title and arrow.
react-aria-components
Preview
"use client";
import { Info } from "lucide-react";
import { Button } from "@/components/ui/button";
import { IconButton } from "@/components/ui/icon-button";
import { Popover, PopoverTrigger } from "@/components/ui/popover";
import { Switch } from "@/components/ui/switch";
export default function Example() {
return (
<div className="flex items-center gap-4">
<PopoverTrigger>
<IconButton aria-label="About AI score">
<Info />
</IconButton>
<Popover title="How the AI score works" showArrow className="w-72">
<p className="text-sm text-fg-secondary">Scores combine ICP fit (60%) and fresh buying signals (40%). Anything above 80 is considered hot.</p>
</Popover>
</PopoverTrigger>
<PopoverTrigger>
<Button>Display options</Button>
<Popover placement="bottom start" className="w-64">
<div className="flex flex-col gap-3">
<Switch defaultSelected>Show AI score</Switch>
<Switch>Compact rows</Switch>
<Switch defaultSelected>Group by company</Switch>
</div>
</Popover>
</PopoverTrigger>
</div>
);
}Installation
Components are copied into your project — no runtime package.
Install the following dependencies:
terminalnpm install react-aria-componentsCreate a
popover.tsxfile and paste the following code into it.src/components/ui/popover.tsx"use client"; import type { ReactNode } from "react"; import { Dialog, DialogTrigger, Heading, OverlayArrow, Popover as AriaPopover, type PopoverProps as AriaPopoverProps } from "react-aria-components"; import { cx } from "@/utils/cx"; export { DialogTrigger as PopoverTrigger }; export interface PopoverProps extends Omit<AriaPopoverProps, "className" | "children"> { title?: string; /** Small arrow pointing at the trigger. */ showArrow?: boolean; className?: string; children: ReactNode; } /** Non-modal floating panel anchored to a trigger. Closes on outside click or Escape. */ export function Popover({ title, showArrow, className, children, offset = 8, ...props }: PopoverProps) { return ( <AriaPopover {...props} offset={offset} className={cx("group rounded-md bg-surface shadow-popover outline-none", className)}> {showArrow && ( <OverlayArrow> <svg width={12} height={12} viewBox="0 0 12 12" className="block fill-surface stroke-line group-data-[placement=bottom]:rotate-180 group-data-[placement=left]:-rotate-90 group-data-[placement=right]:rotate-90"> <path d="M0 0 L6 6 L12 0" /> </svg> </OverlayArrow> )} <Dialog className="p-4 outline-none"> {title && ( <Heading slot="title" className="mb-2 text-base font-medium text-fg"> {title} </Heading> )} {children} </Dialog> </AriaPopover> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.