alwkala

Dropdown Menu

Component

About

A toggleable contextual menu that opens from a trigger element to show a list of actions, links, checkboxes or radio options.

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

Code

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

Usage.tsx

import React from "react";
import {
  Dropdown,
  DropdownTrigger,
  DropdownMenu,
  DropdownHeader,
  DropdownSeparator,
  DropdownCheckboxItem,
  DropdownRadioGroup,
  DropdownRadioItem,
} from "@/components/ui/dropdown";

export default function DropdownCheckboxRadioDemo() {
  const [showGrid, setShowGrid] = React.useState(true);
  const [showLabels, setShowLabels] = React.useState(false);
  const [view, setView] = React.useState("grid");

  return (
    <div className="flex min-h-[360px] w-full items-start justify-center bg-background p-16 text-foreground">
      <Dropdown>
        <DropdownTrigger>
          <button
            type="button"
            className="inline-flex items-center gap-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm hover:bg-accent"
          >
            <span>View options</span>
            <svg
              width="14"
              height="14"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              strokeWidth="2"
              strokeLinecap="round"
              strokeLinejoin="round"
              aria-hidden="true"
            >
              <polyline points="6 9 12 15 18 9" />
            </svg>
          </button>
        </DropdownTrigger>
        <DropdownMenu>
          <DropdownHeader>Display</DropdownHeader>
          <DropdownCheckboxItem
            checked={showGrid}
            onCheckedChange={setShowGrid}
          >
            Show grid lines
          </DropdownCheckboxItem>
          <DropdownCheckboxItem
            checked={showLabels}
            onCheckedChange={setShowLabels}
          >
            Show labels
          </DropdownCheckboxItem>
          <DropdownSeparator />
          <DropdownHeader>Layout</DropdownHeader>
          <DropdownRadioGroup value={view} onValueChange={setView}>
            <DropdownRadioItem value="grid">Grid view</DropdownRadioItem>
            <DropdownRadioItem value="list">List view</DropdownRadioItem>
            <DropdownRadioItem value="compact">Compact view</DropdownRadioItem>
          </DropdownRadioGroup>
        </DropdownMenu>
      </Dropdown>
    </div>
  );
}

More by alwkala

View all
  • Callout

    Callout

    10
  • Progress Bar

    Progress Bar

    2
  • Breadcrumb

    Breadcrumb

    1
  • Navbar

    Navbar

    1
  • Kbd

    Kbd

  • Pagination

    Pagination

  • Back To Top

    Back To Top

  • Checkbox

    Checkbox