Dev Helpers
← Back

Native popover trigger

Import and render <NativePopoverTrigger /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/NativePopoverTrigger.tsx

import { useId } from "react";

import type { ReactNode } from "react";

export default function NativePopoverTrigger({
  title = "Delivery",
  children = "Arrives in two days.",
}: { title?: string; children?: ReactNode } = {}) {
  const id = useId();
  return (
    <>
      <button popoverTarget={id}>{title}</button>
      <aside id={id} popover="auto">
        {children}
      </aside>
    </>
  );
}