Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Model Selector for Vue

Two menus in the chat composer that set the model and the reasoning effort for the next message, built from Dropdown Menu for Vue on Ark UI.

On this page10 sections
UI library: Ark UI

Model Selector is the pair of small menus in a chat composer that decide what the next message runs on: one picks the model, the other how much reasoning effort it gets. Each trigger shows the current choice, so the setting stays visible without opening anything.

Each menu is a Dropdown Menu of radio items in the field's Input Group. For the whole composer with attachments, start from Prompt Input. With dozens of models, a searchable Combobox serves the list better.

Preview width

Installation

Model Selector is a pattern. The command adds the parts it's built from, Dropdown Menu and Input Group, and the code to copy is the demo's.

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Model Selector anatomy: content, label, radio item, separator, trigger, input group

Usage

import { ArrowUpIcon, ChevronDownIcon } from "lucide-react";
import { useState } from "react";
import {
  DropdownMenu, DropdownMenuContent, DropdownMenuLabel,
  DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
  InputGroup, InputGroupAddon, InputGroupButton, InputGroupTextarea,
} from "@/components/ui/input-group";
const models = [
  { id: "gpt-5", name: "GPT-5" },
  { id: "gpt-5-mini", name: "GPT-5 mini" },
];

const efforts = [
  { id: "low", name: "Low" },
  { id: "medium", name: "Medium" },
  { id: "high", name: "High" },
];

export function ModelSelector() {
  const [model, setModel] = useState("gpt-5");
  const [effort, setEffort] = useState("medium");
  const modelName = models.find((item) => item.id === model)?.name;
  const effortName = efforts.find((item) => item.id === effort)?.name;

  return (
    <InputGroup>
      <InputGroupTextarea
        aria-label="Message"
        placeholder="Ask the agent to change your code..."
      />
      <InputGroupAddon align="block-end">
        <DropdownMenu positioning={{ placement: "bottom-start" }}>
          <DropdownMenuTrigger asChild>
            <InputGroupButton
              aria-label={`Model: ${modelName}`}
              size="sm"
              variant="outline"
            >
              {modelName}
              <ChevronDownIcon aria-hidden="true" />
            </InputGroupButton>
          </DropdownMenuTrigger>
          <DropdownMenuContent>
            <DropdownMenuRadioGroup
              onValueChange={(details) => setModel(details.value)}
              value={model}
            >
              <DropdownMenuLabel>OpenAI</DropdownMenuLabel>
              {models.map((item) => (
                <DropdownMenuRadioItem key={item.id} value={item.id}>
                  {item.name}
                </DropdownMenuRadioItem>
              ))}
            </DropdownMenuRadioGroup>
          </DropdownMenuContent>
        </DropdownMenu>
        <DropdownMenu positioning={{ placement: "bottom-start" }}>
          <DropdownMenuTrigger asChild>
            <InputGroupButton
              aria-label={`Effort: ${effortName}`}
              size="sm"
              variant="outline"
            >
              {effortName}
              <ChevronDownIcon aria-hidden="true" />
            </InputGroupButton>
          </DropdownMenuTrigger>
          <DropdownMenuContent>
            <DropdownMenuRadioGroup
              onValueChange={(details) => setEffort(details.value)}
              value={effort}
            >
              {efforts.map((item) => (
                <DropdownMenuRadioItem key={item.id} value={item.id}>
                  {item.name}
                </DropdownMenuRadioItem>
              ))}
            </DropdownMenuRadioGroup>
          </DropdownMenuContent>
        </DropdownMenu>
        <InputGroupButton
          aria-label="Send"
          className="ms-auto"
          pill
          size="icon-sm"
          type="submit"
          variant="default"
        >
          <ArrowUpIcon aria-hidden="true" />
        </InputGroupButton>
      </InputGroupAddon>
    </InputGroup>
  );
}

Each DropdownMenuRadioGroup holds one id as its value, and picking an item closes the menu and hands the new id to your state. The demo adds a second provider to the model menu as another labelled group, with a separator between the two.

Accessibility

Each trigger is a button with aria-haspopup and aria-expanded, and its menu takes its name from the trigger. The models are radio items that report aria-checked, each provider label names its group, and picking a model or pressing Escape returns focus to the trigger. Naming the triggers is your part: the visible text is only the value, so give each one an aria-label that says the setting too, as the demo's Model: GPT-5 does.

Enter
When focus is on a trigger, opens its menu and highlights the first item. On a highlighted item, picks it and closes the menu.
Space
When focus is on a trigger, opens its menu and highlights the first item. On a highlighted item, picks it and closes the menu.
Arrow Down
When focus is on a trigger, opens its menu on the first item. In the menu, highlights the next item and stops at the last one.
Arrow Up
When focus is on a trigger, opens its menu on the last item. In the menu, highlights the previous item and stops at the first one.
Home
Highlights the first item in the menu.
End
Highlights the last item in the menu.
Escape
Closes the menu without a change and moves focus back to its trigger.

AI SDK

The menus only hold the choice. Send the model and the effort with each message, and map them to a model and its provider options in the route.

import { Chat } from "@ai-sdk/vue";

const chat = new Chat({});

chat.sendMessage({ text }, { body: { effort, model } });

Your server route reads model and effort from the request body next to messages, picks the provider's model, and passes the effort to streamText as provider options (openai: { reasoningEffort }, anthropic: { effort }).

Each provider reads its own key in providerOptions and ignores the rest. Look the model up in a table of the ones you offer, so a request can't pick a model you didn't list.

Migrating from AI SDK Elements

AI SDK Elements is for React. In Vue, start from the demo above: its two menus are all there is to Model Selector.

FAQ

How do I send the selected model to my AI SDK chat route?

Pass the model's id and the effort in the body of each request, next to the messages, and pick the model on the server from a table of the ones you offer. The menus keep the choice in the browser, and the server only learns it from the request.

In the route, read the two values from the request body, look the id up in your table, and pass the effort to streamText in providerOptions, under the key each provider reads. The AI SDK section shows both halves, and a lookup that falls back to a default means a forged id can't reach a model you never listed.

How do I set the default model in a model selector?

Start the state with the model's id, as the demo does with GPT-5, and the radio group shows it checked from the first render. Clicking the checked item again leaves it checked, so a model is always chosen once the state has one.

To remember the last pick between visits, save the id to localStorage or the user's settings when it changes and read it back as the starting state. Check that the saved id is still in your list, since models get retired.

Should a model picker be a dropdown menu, a select or a combobox?

A Dropdown Menu of radio items suits a short list. Its trigger sits in the composer's row of buttons, the models group under provider labels, and the current one shows a check.

A Select does the same job and fits better when the choice is a field in a form that submits. Once the list runs to dozens of models, people need to type to find one, so move to a Combobox or a Command list in a popover.

What should the model selector's trigger button show?

The current choice, in as few words as the composer's single row allows: GPT-5 for the model, and Effort Medium for the effort, with the word Effort muted so the value stands out.

Give each trigger an aria-label that names the setting and its value, such as Model: GPT-5. A screen reader otherwise hears GPT-5 on its own, with no word on what the button changes, and the menu takes its name from that same label.

How do I disable a model in the model selector for free users?

Set disabled on that model's DropdownMenuRadioItem. It stays in the list, dimmed, and can't be picked with the pointer or the keyboard, which tells people the model exists on a higher plan.

Say why in the item, with a short Pro label after the name, and keep the server's check as well: a disabled item stops a click, not a request that names that model.

How do I add provider logos to model selector items?

Put the logo before the name inside each item, as an icon or a small image with aria-hidden set, so a screen reader reads only the model's name. Typing a letter in the open menu still finds an item by its text, and the logo adds none.

When every model of a provider shares one logo, put it once beside the provider's label instead of on each row, and the list stays easier to scan.

Can people pick a model with the keyboard?

Yes. Tab reaches each trigger, and Enter, Space or the down arrow opens its menu on the first item. The arrow keys move through the models, Enter picks one and closes the menu, and Escape closes it without a change and returns focus to the trigger.

The Accessibility section lists each key.

Is this the same as AI SDK Elements' Model Selector?

It does the same job in less room. AI SDK Elements built its Model Selector as a searchable list in a Dialog, while here each choice is a Dropdown Menu in the message field, with no search.

AI SDK Elements ships for React only, so in Vue there is no old file to convert. Copy the demo's two menus into your own composer and change the list of models.

API Reference

Model Selector has no props of its own. Each menu is a Dropdown Menu: the selected value and its change handler, the items, labels and separators are Dropdown Menu's. The field, its addon and the trigger and send buttons are Input Group's.