Shehryar Ali

Selection Actions

AI chats 2

About

Highlight a passage and hand it to an AI: a floating action bar with prompt input, quick actions, a streamed rewrite and keep or discard.

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

Code

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

Usage.tsx

import SelectionActions, { ActionIcon, type SelectionActionSet } from "@/components/ui/selection-actions";

/* all content lives here; the component only renders what it is given */

const ACTIONS: SelectionActionSet = {
  primary: [
    {
      id: "explain",
      label: "Explain",
      icon: (
        <ActionIcon>
          <path d="M21 12a8 8 0 0 1-11.6 7.1L4 21l1.9-5.4A8 8 0 1 1 21 12z" />
          <path d="M9.8 9.6a2.3 2.3 0 0 1 4.4.9c0 1.5-2.2 2-2.2 2M12 15.5h.01" />
        </ActionIcon>
      ),
    },
    {
      id: "improve",
      label: "Improve",
      action: "Improve",
      busyLabel: "Improving",
      icon: (
        <ActionIcon>
          <path d="M12 3c.6 4.5 2.5 6.4 7 7-4.5.6-6.4 2.5-7 7-.6-4.5-2.5-6.4-7-7 4.5-.6 6.4-2.5 7-7z" />
        </ActionIcon>
      ),
    },
  ],
  more: [
    {
      id: "shorten",
      label: "Shorten",
      action: "Shorten",
      busyLabel: "Shortening",
      result: "Roll out to 10% of workspaces first and watch error rates for a day before going wider.",
      icon: (
        <ActionIcon>
          <circle cx="6" cy="6" r="3" />
          <circle cx="6" cy="18" r="3" />
          <path d="M20 4 8.1 15.9M14.5 14.5 20 20M8.1 8.1 12 12" />
        </ActionIcon>
      ),
    },
    {
      id: "tone",
      label: "Tone",
      action: "Change tone",
      busyLabel: "Changing tone",
      icon: (
        <ActionIcon>
          <circle cx="12" cy="12" r="9" />
          <path d="M8.5 14a4 4 0 0 0 7 0M9 9.5h.01M15 9.5h.01" />
        </ActionIcon>
      ),
    },
    {
      id: "grammar",
      label: "Grammar",
      action: "Fix grammar",
      busyLabel: "Fixing grammar",
      icon: (
        <ActionIcon>
          <rect x="3" y="4" width="18" height="16" rx="2" />
          <path d="M7 9h10M7 13h6" />
        </ActionIcon>
      ),
    },
  ],
};

export default function SelectionActionsDemo() {
  return (
    <div className="flex min-h-[520px] w-full items-center justify-center bg-background p-8">
      <SelectionActions
        lead="The new billing flow passed every check in staging. "
        original="We should roll it out to around ten percent of workspaces at first, and then keep an eye on the error rates for a day or so before going wider."
        rewrite="Roll it out to 10% of workspaces first, then monitor error rates for 24 hours before expanding to everyone."
        actions={ACTIONS}
        onAction={(action) => console.log("action:", action)}
        onKeep={(text) => console.log("keep:", text)}
      />
    </div>
  );
}

More by Shehryar Ali

View all
  • Loading State

    Loading State

    20
  • Insight Cards

    Insight Cards

    10
  • Streaming Text

    Streaming Text

    9
  • Flowchart

    Flowchart

    5
  • Filter Table

    Filter Table

    3
  • Murmur Ember Silk

    Murmur Ember Silk

    3
  • Thinking State

    Thinking State

    2
  • Murmur Ember Tide

    Murmur Ember Tide

    1

More in AI chats

View all
  • Agent Chat

    Agent Chat

    21
  • AI Suggestions

    AI Suggestions

    27
  • AI Actions

    AI Actions

    372
  • Interactive LLM Token & Context Window Visualizer

    Interactive LLM Token & Context Window Visualizer

    30
  • Aquarium Prompt

    Aquarium Prompt

    223
  • Message Parts

    Message Parts

    11
  • AI SaaS Workflow Hero

    AI SaaS Workflow Hero

    37
  • AI Chat Composer

    AI Chat Composer

    22