Skip to main content
A beautiful dropdown selector component for choosing AI models, featuring model icons, provider labels, pro badges, and optional descriptions.

Installation

    Usage

    import { useState } from "react";
    import { ModelSelector, type AIModel } from "@/components/ui/model-selector";
    
    const models: AIModel[] = [
      {
        id: "gpt-4o",
        name: "GPT-4o",
        provider: "OpenAI",
        icon: "https://example.com/openai-icon.svg",
        isPro: true,
        description: "Most capable model for complex tasks",
      },
      {
        id: "claude-3.5",
        name: "Claude 3.5 Sonnet",
        provider: "Anthropic",
        icon: "https://example.com/anthropic-icon.svg",
        isPro: true,
        description: "Advanced reasoning and analysis",
      },
      {
        id: "gemini-pro",
        name: "Gemini Pro",
        provider: "Google",
        description: "Fast and efficient for most tasks",
      },
    ];
    
    export default function Example() {
      const [selectedModel, setSelectedModel] = useState(models[0]);
    
      return (
        <ModelSelector
          models={models}
          selectedModel={selectedModel}
          onSelect={setSelectedModel}
        />
      );
    }
    

    Props

    models
    AIModel[]
    required
    Array of AI models to display in the selector. Each model should have:
    • id: Unique identifier
    • name: Display name
    • provider: Provider name (e.g., “OpenAI”, “Anthropic”)
    • icon: Optional icon URL
    • isPro: Optional boolean to show PRO badge
    • description: Optional description text
    selectedModel
    AIModel
    required
    The currently selected model object.
    onSelect
    (model: AIModel) => void
    required
    Callback function called when a model is selected. Receives the selected model object.
    disabled
    boolean
    default:"false"
    Whether the selector is disabled.
    className
    string
    Additional CSS classes to apply to the root element.

    Types

    export interface AIModel {
      id: string;
      name: string;
      provider: string;
      icon?: string;
      isPro?: boolean;
      description?: string;
    }
    
    export interface ModelSelectorProps {
      models: AIModel[];
      selectedModel: AIModel;
      onSelect: (model: AIModel) => void;
      disabled?: boolean;
      className?: string;
    }
    

    Features

    • Model Icons: Display custom icons for each model or fallback to default AI icon
    • Provider Labels: Show the AI provider with a green status indicator
    • Pro Badges: Highlight premium models with animated gradient badges
    • Descriptions: Optional descriptions for each model in the dropdown
    • Smooth Animations: Subtle fade and scale animations when opening
    • Keyboard Support: Escape key closes the dropdown
    • Scroll Support: Scrollable dropdown with custom scrollbar styling
    • Selected State: Visual indicator showing the currently selected model
    • Dark Mode: Full support for light and dark themes
    • Disabled State: Prevents interaction when disabled

    Accessibility

    • Semantic button elements for proper keyboard navigation
    • aria-label on backdrop for screen readers
    • Focus indicators on interactive elements
    • Disabled state properly handled
    • Keyboard support (Escape to close)
    • Proper button types to prevent form submission

    Build docs developers (and LLMs) love