Skip to content
Back

Model switcher

The model menu of an agent app: providers, favourites and recents, search, capability badges, a model that needs a key or is rate limited, Auto routing and a change that waits for the next turn.

oxyn add model-switcher
MCP
Dioxus
rsx! {
    ModelPicker {
        catalog: models(),
        selected: model(),
        picker: picker() // popover state: open, query, highlight,
        favorites: favorites(),
        now: clock.now(),
        on_choose: move |m: ModelSelection| model.set(m),
    }
}

Rendered from Rust at build time · goes live when visible

When to use

  • The model pill sits in the composer's control row (usually right of +, left of the send control).
  • The user is choosing who does the next piece of work: a cheaper/faster model for a quick question, a reasoning model for a hard refactor, a vision model because an image is attached, or "Auto" so the app routes for them.
  • The picker must answer three questions at a glance: *what will run next*, *can it do what my message needs* (images, tools, context length), and *what will it cost me in time and money*.
  • It also has to be honest when a model cannot run right now (no key, rate-limited, down) and behave predictably when the user switches while an agent is mid-run.

When not to use

  • How hard the model thinks: use Effort control instead.
  • How full the context window is: use Context meter instead.
  • Prompt composer with model picker, voice input, app connections and approval request: use Chat Composer instead.

Installation

Model switcher is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.

Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add model-switcher
Rust
use crate::oxyn::{ModelPicker, COMPOSER_CSS};

Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{ModelPicker, COMPOSER_CSS};

Usage

Dioxus · rust
rsx! {
    ModelPicker {
        catalog: models(),
        selected: model(),
        picker: picker() // popover state: open, query, highlight,
        favorites: favorites(),
        now: clock.now(),
        on_choose: move |m: ModelSelection| model.set(m),
    }
}

Examples

Open

The full list.

Code
rsx! {
    ModelPicker {
        catalog: models(),
        selected: model(),
        picker: picker() // popover state: open, query, highlight,
        favorites: favorites(),
        now: clock.now(),
        on_choose: move |m: ModelSelection| model.set(m),
    }
}

Search

Searching "dp".

Code
rsx! {
    ModelPicker {
        catalog: models(),
        selected: model(),
        picker: picker() // popover state: open, query, highlight,
        favorites: favorites(),
        now: clock.now(),
        on_choose: move |m: ModelSelection| model.set(m),
    }
}

Pending

Deep 2 from the next turn.

→ Claude Opus 5
Code
rsx! {
    ModelPicker {
        catalog: models(),
        selected: model(),
        picker: picker() // popover state: open, query, highlight,
        favorites: favorites(),
        now: clock.now(),
        on_choose: move |m: ModelSelection| model.set(m),
    }
}

Favorites segmented

Favourites as segments.

Code
rsx! {
    ModelPicker {
        catalog: models(),
        selected: model(),
        picker: picker() // popover state: open, query, highlight,
        favorites: favorites(),
        variant: "favorites-segmented",
        now: clock.now(),
        on_choose: move |m: ModelSelection| model.set(m),
    }
}

Glyph

Terminal picker.

Select model
1. Auto
2. GPT-6 Vision 256K
›3. Claude Haiku 5 200K (current)
4. Claude Opus 5 1M
5. Local Q 7B 32K
6. GPT-6 128K
↑↓ move · enter select · esc close
Code
rsx! {
    ModelPicker {
        catalog: models(),
        selected: model(),
        picker: picker() // popover state: open, query, highlight,
        favorites: favorites(),
        variant: "glyph",
        now: clock.now(),
        on_choose: move |m: ModelSelection| model.set(m),
    }
}

API reference

ModelPicker

PropTypeDefaultDescription
catalogrequiredModelCatalog—Host catalogue.
selectedrequiredModelSelection—Selected model.
pendingOption<ModelSelection>Default::default()Waiting for the next turn (`→ Deep 4` badge).
pickerrequiredPicker—Popover state.
favoritesVec<String>Default::default()Favourites (★, cycle order).
recentVec<String>Default::default()Recently used, newest first.
needsDraftNeedsDefault::default()What the draft needs (incompatibility notes).
routingboolDefault::default()Auto is resolving during a run (three breathing dots).
variantString"pill-popover"`pill-popover` · `morph-list` · `command` · `glyph` · `compact` · `favorites-segmented`.
nowrequiredClockMs—Shared clock time (countdowns, routing dots).
on_toggleEventHandler<()>—Pill pressed.
on_keyEventHandler<PickerKey>—A key in the popover.
on_queryEventHandler<String>—Search text changed.
on_chooseEventHandler<ModelSelection>—A row chosen.
on_cancel_pendingEventHandler<()>—Pending badge × pressed.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
↑or↓Move through models
EnterChoose
EscClose
TypeSearch

Accessibility

  • The pill is a button with aria-haspopup=listbox and a full name ("Model: Claude Haiku 5. Change model").
  • Search is a combobox controlling a listbox; unavailable models are aria-disabled with the reason.
  • Capability badges have text alternatives, never colour only.
From the spec
  • Pill: button, aria-haspopup="listbox", aria-expanded. Label per state, e.g. "Model: Claude Sonnet 5. Change model", "Model: Auto, routed to Sonnet 5", "Model: Opus, rate limited, resets in 4 minutes", "Model locked by workspace policy".
  • Popover: search field is a combobox controlling a listbox; groups are group with labels; rows are option with aria-selected and aria-disabled + aria-describedby → reason text.
  • Capability badges are icons with text alternatives ("vision", "tools", "reasoning", "200 thousand token context", "fast", "cost: high"); never colour-only.
  • Live region (polite): "12 models match", "No matches", "Switched to Opus", "Opus will be used from your next message", "Opus available again". Countdown is not announced every second; only at 60 s and 0.
  • Focus order: search → Auto → Recent → Favourites → groups → footer link. Esc returns focus to the pill.
  • Contrast: row text ≥ 4.5:1; dimmed unavailable rows keep reason text ≥ 4.5:1 (only the name dims).
  • Reduced motion honoured from the global token.

Motion & interaction

  • Hover: chip bg fades to chip.hover; chevron translates +1 px y. No lift/shadow (control row stays flat).
  • Press: chip scales to 0.97 on pointer-down, springs back on release.
  • Focus ring: 2 px focus.ring, offset 2 px, appears without animation on keyboard focus only.
  • Open: the popover grows out of the pill: origin = pill's top-centre, scale 0.96 → 1, y +4 px → 0, opacity 0 → 1. Variant morph-list instead grows the pill surface itself into the list (corner
  • Rows enter: first 8 rows stagger 18 ms each (cap 144 ms); rows beyond 8 appear with the list.
  • Highlight: one shared highlight rect glides between rows (spring) instead of per-row hover fades.
  • Detail tray (footer strip, 44 px): shows context size, speed, cost for the highlighted row; numeric values roll (tabular digits) when the highlight moves.
  • Capability badges: 16 px square icons with 1 px stroke; on search-filter toggle, matching badges pulse once (opacity 1 → 0.6 → 1).
  • Select: the chosen row's name lifts and flies to the pill (shared-element, ≤ 260 ms), pill width springs to fit, label rolls up if the new model is above the old one in list order, down if Below.
  • Close: reverse of open, faster, no overshoot.
  • PendingNext badge: "→ Opus" slides out of the pill's right edge (x −6 → 0, opacity) with a dashed 1 px outline; on run end it merges into the pill (badge collapses, label rolls).
  • Routing (Auto): three 3 px dots in the mark slot breathe in sequence; on resolve, dots collapse to the provider mark (scale 0 → 1) and the secondary label types in.
  • RateLimited countdown: m:ss digits roll each second; at 0 the row's clock glyph morphs to the provider mark and the row un-dims.
  • Error (CatalogError): retry button shakes 2 cycles × 4 px only after a failed retry.
Timing
TransitionDurationDelayEasing / springNotes
Hover bg80 ms0ease-out—
Tooltip120 ms fade500 msease-out—
Press scale 0.97 ↔ 1~120 ms0spring stiffness 600, damping 30close to button springs reported for Claude desktop [research 08 §1.4, RE]
Popover open (scale/opacity/y)~200 ms settle0spring 380 / 32no visible overshoot
Popover close120 ms0ease-in—
Row stagger18 ms × index, cap 8 rows40 msease-out 140 ms each—
Highlight glide~120 ms0spring 500 / 40—
Detail tray digit roll320 ms0cubic-bezier(0.22, 1, 0.36, 1)shorter cousin of OpenCode AnimatedNumber 560 ms [research 08 §1.5, MIT]
Name fly to pill≤ 260 ms0ease-in-out—
Pill width~240 ms0spring 300 / 30—
Label roll220 ms0cubic-bezier(0.22, 1, 0.36, 1)direction by list order
PendingNext badge in180 ms0ease-out—
Routing dots1.2 s loop, 150 ms stagger0sineshared motion clock
Skeleton rows1.6 s sweep150 ms gracelinear—
Search filter0 ms (instant)debounce 60 ms—list reorders without animation
Countdown digit200 ms0ease-out1 Hz
Frame ratedisplay rate (GPUI) / rAF (Dioxus); idle = no frames———
Reduced motionopen/close = 100 ms opacity only; no stagger, no fly, no roll (labels swap); routing dots static …; highlight jumps—linear—

Responsive behaviour

  • compact shows only the short name; the list opens upward from a bottom composer.
Edge cases (spec)
  • Long names ("Claude Sonnet 5.5 Thinking 1M"): pill uses short_name if supplied, else end-ellipsis at max_pill_width; popover rows wrap to 2 lines max, then ellipsis with full name in tooltip.
  • Many models (OpenRouter-style 300+): virtualised list (row height fixed 36 px / 48 px two-line), search auto-focused when models.len() > 12, provider groups collapsible, group headers sticky.
  • Duplicate names across providers: always show provider mark + provider name in the row's second line.
  • RTL: chevron moves to the left; list and tray mirror; digits stay LTR in tabular figures.
  • Tiny sizes (16–20 px row): compact variant only: 16 px mark, no label, badge dots 4 px; the warning/limit state becomes a 4 px corner dot (amber/red) plus tooltip text.
  • Dense IDE panels: popover max height = min(420 px, 60 % of panel); opens below if above-space < 240 px.
  • Touch: popover becomes a bottom sheet (snap points 50 % / 90 %), rows 44 px, ★ needs long-press.
  • Slow networks: catalog fetched once and cached with timestamp; stale list usable, "Updated 3 h ago" in footer; validation calls never block selection.
  • Very fast agents: if the run ends within 300 ms of a mid-run selection, PendingNext is skipped and the switch applies directly (no badge flash).
  • Very slow agents: PendingNext badge persists for the whole run; hovering it explains "Applies to your next message".
  • Selected model removed from catalog: pill keeps the old label with warning dot and "No longer available · Choose another"; send control goes Disabled(reason) until a choice is made.
  • Key added in another window: catalog event updates rows live; NeedsKey rows animate to available.
  • Attachments added after selection that the model can't read: pill shows warning dot; send control shows the reason; no automatic switch (we never change the model behind the user's back).
  • Auto never resolves (adapter doesn't report): pill stays "Auto"; no fake model name.

Notes for AI

  • Import ModelPicker from oxyn_dioxus and include COMPOSER_CSS plus the token stylesheet once.
  • A GPUI version exists: ModelPickerEl in oxyn_gpui.
  • Props to set first: catalog, selected, picker, now.
  • It reads a clock (now) for live timers; pass one clock for the whole page rather than one per component.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI