# Context menu

> A compact frosted menu that drops from a “more” button with actions like copy, share and delete.

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

## Where to use it

The three-dots button hides actions that are useful but not constant: copy a link to a document, share a photo from a gallery, delete a draft in a CMS. The blurred glass background keeps it light, like the menus on a Mac. It is a simple dropdown context menu in React that fits file lists, cards and table rows.

Put destructive actions such as “Delete” last and consider coloring them red. Raise the blur if the menu opens over busy images, lower it over plain backgrounds. More than six items usually means some belong elsewhere.

## Code

### React (Motion)

```tsx
import { useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { ChevronRight, Copy, Link2, MoreHorizontal, Share2, Trash2 } from "lucide-react";

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

const ITEMS = [
  { icon: Copy, label: "Copy" },
  { icon: Link2, label: "Copy link" },
  { icon: Share2, label: "Share" },
  { icon: Trash2, label: "Delete" },
];

interface ContextMenuProps {
  blur?: number;
}

export default function ContextMenu({ blur = 20 }: ContextMenuProps) {
  const [open, setOpen] = useState(false);

  return (
    <div className="relative text-[#1d1d1f] dark:text-[#f5f5f7]">
      <button
        type="button"
        aria-label="More actions"
        aria-expanded={open}
        onClick={() => setOpen((o) => !o)}
        className="grid h-12 w-12 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)]"
      >
        <MoreHorizontal />
      </button>
      <AnimatePresence>
        {open && (
          <motion.div
            initial={{ opacity: 0, scale: 0.9, y: -6 }}
            animate={{ opacity: 1, scale: 1, y: 0 }}
            exit={{ opacity: 0, scale: 0.9 }}
            transition={spring}
            className="absolute left-1/2 top-14 z-10 w-48 -translate-x-1/2 rounded-2xl border border-black/10 bg-white/70 p-1.5 shadow-[0_4px_12px_rgba(0,0,0,0.04),0_24px_60px_rgba(0,0,0,0.1)] dark:border-white/10 dark:bg-black/70"
            style={{ backdropFilter: `blur(${blur}px)` }}
          >
            {ITEMS.map(({ icon: Icon, label }) => (
              <button
                key={label}
                type="button"
                className="flex w-full items-center gap-2 rounded-xl px-3 py-2 text-sm hover:bg-black/5 dark:hover:bg-white/10"
              >
                <Icon className="h-4 w-4" />
                {label}
                <ChevronRight className="ml-auto h-3 w-3" />
              </button>
            ))}
          </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 “Context menu” block (Overlays) from AIMRAN Library to my project.

## What it is
A compact frosted menu that drops from a “more” button with actions like copy, share and delete.

## Chosen settings
- Blur: 20px (from 8 to 30px)

## 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 { ChevronRight, Copy, Link2, MoreHorizontal, Share2, Trash2 } from "lucide-react";

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

const ITEMS = [
  { icon: Copy, label: "Copy" },
  { icon: Link2, label: "Copy link" },
  { icon: Share2, label: "Share" },
  { icon: Trash2, label: "Delete" },
];

interface ContextMenuProps {
  blur?: number;
}

export default function ContextMenu({ blur = 20 }: ContextMenuProps) {
  const [open, setOpen] = useState(false);

  return (
    <div className="relative text-[#1d1d1f] dark:text-[#f5f5f7]">
      <button
        type="button"
        aria-label="More actions"
        aria-expanded={open}
        onClick={() => setOpen((o) => !o)}
        className="grid h-12 w-12 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)]"
      >
        <MoreHorizontal />
      </button>
      <AnimatePresence>
        {open && (
          <motion.div
            initial={{ opacity: 0, scale: 0.9, y: -6 }}
            animate={{ opacity: 1, scale: 1, y: 0 }}
            exit={{ opacity: 0, scale: 0.9 }}
            transition={spring}
            className="absolute left-1/2 top-14 z-10 w-48 -translate-x-1/2 rounded-2xl border border-black/10 bg-white/70 p-1.5 shadow-[0_4px_12px_rgba(0,0,0,0.04),0_24px_60px_rgba(0,0,0,0.1)] dark:border-white/10 dark:bg-black/70"
            style={{ backdropFilter: `blur(${blur}px)` }}
          >
            {ITEMS.map(({ icon: Icon, label }) => (
              <button
                key={label}
                type="button"
                className="flex w-full items-center gap-2 rounded-xl px-3 py-2 text-sm hover:bg-black/5 dark:hover:bg-white/10"
              >
                <Icon className="h-4 w-4" />
                {label}
                <ChevronRight className="ml-auto h-3 w-3" />
              </button>
            ))}
          </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.
````
