# Popover with arrow

> A small bubble that grows out of the button that opened it, with an arrow pointing back to its source.

- Category: [Overlays](https://library.aimran.es/components/overlays)
- Built with: React + Motion
- Live editor: https://library.aimran.es/blocks/origin-popover
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Popovers are for the “what does this mean?” moments: a fee next to a price, a hint beside a form field or a plan feature on a pricing table. Because it grows out of the button with an arrow, it is obvious where the information comes from. Few components help a confusing form as much as a well-placed popover.

Keep the text to two lines or so; anything longer belongs on the page or in a modal. Change the title to the actual question people ask, like “Why do we need your phone?”, rather than a generic heading.

## Code

### React (Motion)

```tsx
import { useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { Info } from "lucide-react";

const spring = { type: "spring" as const, stiffness: 300, damping: 30 };

interface PopoverProps {
  title?: string;
}

export default function Popover({ title = "Before you continue" }: PopoverProps) {
  const [open, setOpen] = useState(false);

  return (
    <div className="relative text-[#1d1d1f] dark:text-[#f5f5f7]">
      <button
        type="button"
        aria-label="Information"
        aria-expanded={open}
        onClick={() => setOpen((o) => !o)}
        className="grid h-11 w-11 place-items-center rounded-full bg-white dark:bg-[#1c1c1e] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)]"
      >
        <Info className="h-5 w-5" />
      </button>
      <AnimatePresence>
        {open && (
          <motion.div
            initial={{ opacity: 0, scale: 0.85, y: -8 }}
            animate={{ opacity: 1, scale: 1, y: 0 }}
            exit={{ opacity: 0, scale: 0.9 }}
            style={{ transformOrigin: "top center" }}
            transition={spring}
            className="absolute left-1/2 top-14 z-10 w-56 -translate-x-1/2 rounded-2xl bg-white p-4 text-sm shadow-[0_4px_12px_rgba(0,0,0,0.04),0_24px_60px_rgba(0,0,0,0.1)] dark:bg-[#1d1d1f]"
          >
            <i className="absolute -top-1.5 left-1/2 h-3 w-3 -translate-x-1/2 rotate-45 bg-white dark:bg-[#1d1d1f]" />
            <b>{title}</b>
            <p className="mt-1 text-[#86868b]">Brief, contextual info.</p>
          </motion.div>
        )}
      </AnimatePresence>
    </div>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Popover with arrow” block (Overlays) from AIMRAN Library to my project.

## What it is
A small bubble that grows out of the button that opened it, with an arrow pointing back to its source.

## Chosen settings
- Title: "Before you continue"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with React + TypeScript, with framer-motion for the animation and lucide-react for the icons. If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
import { useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { Info } from "lucide-react";

const spring = { type: "spring" as const, stiffness: 300, damping: 30 };

interface PopoverProps {
  title?: string;
}

export default function Popover({ title = "Before you continue" }: PopoverProps) {
  const [open, setOpen] = useState(false);

  return (
    <div className="relative text-[#1d1d1f] dark:text-[#f5f5f7]">
      <button
        type="button"
        aria-label="Information"
        aria-expanded={open}
        onClick={() => setOpen((o) => !o)}
        className="grid h-11 w-11 place-items-center rounded-full bg-white dark:bg-[#1c1c1e] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)]"
      >
        <Info className="h-5 w-5" />
      </button>
      <AnimatePresence>
        {open && (
          <motion.div
            initial={{ opacity: 0, scale: 0.85, y: -8 }}
            animate={{ opacity: 1, scale: 1, y: 0 }}
            exit={{ opacity: 0, scale: 0.9 }}
            style={{ transformOrigin: "top center" }}
            transition={spring}
            className="absolute left-1/2 top-14 z-10 w-56 -translate-x-1/2 rounded-2xl bg-white p-4 text-sm shadow-[0_4px_12px_rgba(0,0,0,0.04),0_24px_60px_rgba(0,0,0,0.1)] dark:bg-[#1d1d1f]"
          >
            <i className="absolute -top-1.5 left-1/2 h-3 w-3 -translate-x-1/2 rotate-45 bg-white dark:bg-[#1d1d1f]" />
            <b>{title}</b>
            <p className="mt-1 text-[#86868b]">Brief, contextual info.</p>
          </motion.div>
        )}
      </AnimatePresence>
    </div>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
