Waqar H. Syed

Selection context menu

Component 1

About

A floating text selection context toolbar with quick actions to copy, highlight, and annotate passages. Useful in editorial blogs, document readers, and rich text editors to provide contextual inline tools.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Selection context menu to your project and fits it to your theme.

Code

How Selection context menu is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";
import Component, { type Props, type State } from "@/components/ui/selection-context-menu";

const settings = { title: "A little less, but better." };
export const loopDuration = 6;

const ease = (x: number) => {
  const n = Math.max(0, Math.min(1, x));
  return n * n * (3 - 2 * n);
};

const pulse = (t: number, start: number, end: number) =>
  ease((t - start) / 0.3) * (1 - ease((t - end) / 0.3));

// Pure timeline: export frame n by passing n / 60. No timers or network calls.
export function showcase(time: number): State {
  const t = ((time % loopDuration) + loopDuration) % loopDuration;
  const r = pulse(t, 0.6, 3.4);
  return {
    open: r > 0,
    reveal: r,
    active: 1,
    selected: "Good design makes room for what matters.",
    highlighted: t > 3.4 && t < 4.8,
    notice: t > 3.4 && t < 4.8 ? "Passage highlighted locally." : "",
  };
}

export default function Demo(props: any = {}) {
  const { showcaseTime, ...incoming } = props;
  const merged = { ...settings, ...incoming };
  return (
    <div className="w-full min-h-[460px] flex items-center justify-center p-4 sm:p-6 bg-background">
      <Component
        {...merged}
        state={showcaseTime === undefined ? incoming.state : showcase(showcaseTime)}
        seeking={showcaseTime !== undefined || incoming.seeking}
      />
    </div>
  );
}

More by Waqar H. Syed

View all
  • Build Pipeline

    Build Pipeline

    197
  • Focus City

    Focus City

    143
  • Scroll animated timeline

    Scroll animated timeline

    137
  • Storage District

    Storage District

    74
  • Thumbnail image viewer

    Thumbnail image viewer

    64
  • Glowing Pricing Tiers

    Glowing Pricing Tiers

    59
  • Before after comparison

    Before after comparison

    48
  • Featured Project Hero

    Featured Project Hero

    35