Model Selector

A searchable command palette for selecting AI models in your chat interface.

The ModelSelector component provides a searchable command palette interface for selecting AI models. It's built on top of the cmdk library and provides a keyboard-navigable interface with search functionality.

See scripts/model-selector.tsx for this example.

Installation

npx ai-elements@latest add model-selector

Features

  • Searchable interface with keyboard navigation
  • Fuzzy search filtering across model names
  • Grouped model organization by provider
  • Keyboard shortcuts support
  • Empty state handling
  • Customizable styling with Tailwind CSS
  • Built on cmdk for excellent accessibility
  • TypeScript support with proper type definitions

Props

<ModelSelector />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof Dialog>-Any other props are spread to the underlying Dialog component.

<ModelSelectorTrigger />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof DialogTrigger>-Any other props are spread to the underlying DialogTrigger component.

<ModelSelectorContent />

PropTypeDefaultDescription
titleReactNode-Accessible title for the dialog (rendered in sr-only).
...propsReact.ComponentProps<typeof DialogContent>-Any other props are spread to the underlying DialogContent component.

<ModelSelectorDialog />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandDialog>-Any other props are spread to the underlying CommandDialog component.

<ModelSelectorInput />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandInput>-Any other props are spread to the underlying CommandInput component.

<ModelSelectorList />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandList>-Any other props are spread to the underlying CommandList component.

<ModelSelectorEmpty />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandEmpty>-Any other props are spread to the underlying CommandEmpty component.

<ModelSelectorGroup />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandGroup>-Any other props are spread to the underlying CommandGroup component.

<ModelSelectorItem />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandItem>-Any other props are spread to the underlying CommandItem component.

<ModelSelectorShortcut />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandShortcut>-Any other props are spread to the underlying CommandShortcut component.

<ModelSelectorSeparator />

PropTypeDefaultDescription
...propsReact.ComponentProps<typeof CommandSeparator>-Any other props are spread to the underlying CommandSeparator component.

<ModelSelectorLogo />

PropTypeDefaultDescription
providerstringRequiredThe AI provider name. Supports major providers like
...propsOmit<React.ComponentProps<-Any other props are spread to the underlying img element (except src and alt which are generated).

<ModelSelectorLogoGroup />

PropTypeDefaultDescription
...propsReact.ComponentProps<-Any other props are spread to the underlying div element.

<ModelSelectorName />

PropTypeDefaultDescription
...propsReact.ComponentProps<-Any other props are spread to the underlying span element.