Slash Command Dropdown
gaia/slash-command-dropdownFreeComponent
A slash command dropdown for selecting tools and actions with categorization and search.
Install it
npx shadcn@latest add https://ui.heygaia.io/r/slash-command-dropdown.jsonSource
1"use client";23import type React from "react";4import { useEffect, useMemo, useRef } from "react";5import {6 Cancel01Icon,7 HugeiconsIcon,8 Tag01Icon,9 ToolsIcon,10} from "@/components/icons";1112import { cn } from "@/lib/utils";13import { formatToolName, getToolCategoryIcon } from "@/lib/utils/tool-icons";1415export interface Tool {16 /** Unique tool identifier */17 name: string;18 /** Category for grouping tools */19 category: string;20 /** Description shown below tool name */21 description?: string;22 /** Custom icon (defaults to category icon) */23 icon?: React.ReactNode;24}2526export interface SlashCommandMatch {27 tool: Tool;28 score: number;29}3031interface SlashCommandDropdownProps {32 /** List of tools to display */33 matches: SlashCommandMatch[];34 /** Currently selected tool index */35 selectedIndex: number;36 /** Callback when a tool is selected */37 onSelect: (tool: SlashCommandMatch) => void;38 /** Callback when dropdown is closed */39 onClose: () => void;40 /** Position config for the dropdown */41 position: { top?: number; bottom?: number; left: number; width?: number };42 /** Whether the dropdown is visible */43 isVisible: boolean;44 /** If opened via button (shows header) */45 openedViaButton?: boolean;46 /** Currently selected category filter */47 selectedCategory?: string;48 /** Available categories */49 categories?: string[];50 /** Callback when category changes */51 onCategoryChange?: (category: string) => void;52 /** Additional CSS classes */53 className?: string;54 /** Additional inline styles */55 style?: React.CSSProperties;56}5758// Default icon size for consistency59const ICON_SIZE = 20;60const CATEGORY_ICON_SIZE = 16;6162/**63 * Get a default icon for a tool based on its category64 * Always returns an icon - no tool should be without one65 */66const getDefaultToolIcon = (67 tool: Tool,68 size: number = ICON_SIZE,69): React.ReactNode => {70 // If tool has custom icon, use it71 if (tool.icon) return tool.icon;7273 // Try to get category icon74 const categoryIcon = getToolCategoryIcon(tool.category, {75 showBackground: false,76 width: size,77 height: size,78 });7980 // If category icon exists, use it81 if (categoryIcon) return categoryIcon;8283 return (84 <HugeiconsIcon icon={ToolsIcon} size={size} className="text-zinc-400" />85 );86};8788/**89 * Get icon for a category tab90 */91const getCategoryTabIcon = (category: string): React.ReactNode => {92 if (category === "all") {93 return (94 <HugeiconsIcon95 icon={Tag01Icon}96 size={CATEGORY_ICON_SIZE}97 className="text-current"98 />99 );100 }101102// … truncated
What it pulls in
Other registry items
Files it writes
More from gaia
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Area Chartarea-chart | gaia | Components | Free | 1 dep | |
| Author Tooltipauthor-tooltip | gaia | Components | Free | no deps | |
| Bar Chartbar-chart | gaia | Components | Free | 1 dep | |
| Composercomposer | gaia | Components | Free | no deps | |
| Email Compose Cardemail-compose-card | gaia | Components | Free | no deps | |
| Gauge Chartgauge-chart | gaia | Components | Free | 1 dep | |
| GitHub Stars Buttongithub-stars-button | gaia | Components | Free | 1 dep | |
| Holo Cardholo-card | gaia | Components | Free | 1 dep · 2 files |
