21st

Mode Selector

Component 6

About

Standalone mode selector pill button with built-in popover. Bring your own icons or omit them; renders a non-interactive label when given a single mode. Self-contained port from 21st.dev Agent Elements.

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

Code

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

Usage.tsx

import { ModeSelector, type ModeOption } from "@/components/ui/mode-selector";
import { IconInfinity, IconListCheck, IconArrowUp } from "@tabler/icons-react";

const modes: ModeOption[] = [
  { id: "agent", label: "Agent", icon: IconInfinity },
  { id: "plan", label: "Plan", icon: IconListCheck },
];

export default function Demo() {
  return (
    <div className="flex items-center justify-center w-full min-h-screen bg-background p-8 overflow-hidden">
      <div className="w-full max-w-md">
        <div className="rounded-3xl border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-950 p-3 shadow-sm">
          <input
            type="text"
            placeholder="Send a message…"
            className="w-full bg-transparent px-2 py-1.5 text-sm text-neutral-900 dark:text-neutral-100 placeholder:text-neutral-400 dark:placeholder:text-neutral-500 outline-none"
          />
          <div className="flex items-center justify-between mt-1">
            <ModeSelector modes={modes} defaultValue="agent" />
            <button
              type="button"
              aria-label="Send message"
              className="flex items-center justify-center size-7 rounded-full bg-neutral-300 dark:bg-neutral-700 text-neutral-600 dark:text-neutral-300 transition-colors hover:bg-neutral-400 dark:hover:bg-neutral-600"
            >
              <IconArrowUp className="size-4" />
            </button>
          </div>
        </div>
      </div>
    </div>
  );
}

Dependencies

More by 21st

View all
  • Spline Scene

    Spline Scene

    9.4K
  • Testimonials with Marquee

    Testimonials with Marquee

    2.3K
  • Gradient Button

    Gradient Button

    1.9K
  • Pixel Canvas

    Pixel Canvas

    899
  • Animated Blur Number

    Animated Blur Number

    830
  • Empty State

    Empty State

    773
  • Balloons

    Balloons

    753
  • Status Badge

    Status Badge

    639