zanwei GitHub avatar

chatgpt-model-selector

zanwei

Two zero-dependency implementations (JavaScript Web Component and SwiftUI package) of a ChatGPT‑inspired model intelligence picker with magnetic snapping and animated color progression.

Stars

46

7-day growth

No data

Forks

3

Open issues

0

License

MIT

Last updated

2026-07-10

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

Delivers a polished, accessible UI component that works identically on the web and native Apple platforms, with zero dependencies, full VoiceOver support, and CI validation.

Who it is for

  • Web developers building custom selectors with Web Components
  • iOS/macOS developers seeking a reusable SwiftUI picker
  • UI/UX designers exploring animated, accessible controls
  • Open-source contributors interested in cross-platform UI patterns

Use cases

  • Selecting intelligence tiers in an AI chat interface
  • Embedding a model selector in a settings panel
  • Demonstrating Web Component or SwiftUI best practices in tutorials
  • Rapid prototyping of model‐selection UX for AI products

Strengths

  • Zero dependencies – works standalone in the browser and as a Swift package
  • Shared five‑tier magnetic snap and cyan‑to‑violet color progression across both implementations
  • Accessible – supports VoiceOver, Dynamic Type, Reduce Motion, and consistent light appearance
  • CI‑validated with unit tests for deterministic geometry and tier logic

Considerations

  • Requires modern browser features (Web Components, Shadow DOM, Canvas 2D, ResizeObserver)
  • Limited to iOS 17+ and macOS 14+ for the SwiftUI version
  • Stated as an independent experiment, not affiliated with or endorsed by OpenAI – adoption considerations for production use

README quick start

ChatGPT Model Selector

A ChatGPT-inspired model intelligence picker in two zero-dependency implementations:

  • JavaScript: a standards-based Web Component that runs directly in the browser.
  • SwiftUI: a reusable Swift Package for iOS 17+ and macOS 14+, plus a native demo app.

The two versions share the same five intelligence levels, magnetic snapping, animated color progression, reduced-motion behavior, and Ultra celebration.

Demo

https://github.com/user-attachments/assets/1025109b-c19d-42a1-8fb4-a035cc104bbf

JavaScript version

Open index.html in a browser, or include the component in your own page:




Listen for selection changes through the standard change event:

const selector = document.querySelector('chatgpt-model-selector');

selector.addEventListener('change', (event) => {
  console.log(event.detail.index, event.detail.tier, event.detail.model);
});

Web Component API

AttributeTypeDefaultDescription
model-namestringGPT-5.4Model label shown in the trigger and menu
valueinteger 0–41Light, Medium, High, Extra High, or Ultra
  • value gets or sets the tier index.
  • tier returns the current tier name.
  • change emits { index, tier, model } in event.detail.

The component supports modern browsers with Web Components, Shadow DOM, Canvas 2D, and ResizeObserver.

SwiftUI version

Requirements

  • Xcode 16 or newer
  • Swift 6.0 or newer
  • iOS 17 or newer
  • macOS 14 or newer
  • XcodeGen only when regenerating the iOS demo project

Add the package

In Xcode, choose File → Add Package Dependencies and enter:

https://github.com/zanwei/chatgpt-model-selector

Or add the package in Package.swift:

dependencies: [
  .package(
    url: "https://github.com/zanwei/chatgpt-model-selector.git",
    branch: "main"
  )
]

Then add the ChatGPTModelSelector library product to your target.

Use the component

import ChatGPTModelSelector
import SwiftUI

struct ComposerView: View {
  @State private var tier: ModelTier = .medium

  var body: some View {
    ModelSelector(
      modelName: "GPT-5.4",
      selection: $tier
    )
  }
}

The binding is the source of truth: user interaction updates it, and external writes move the sel

Description

ChatGPT-inspired model intelligence picker as a zero-dependency Web Component (MIT)

Related repositories

Similar projects matched by category, topics, and programming language.

react
Featured
react GitHub avatar

react

React is a JavaScript library for building user interfaces with declarative, component-based, and cross-platform design.

Web DevelopmentFrontend Frameworks
246,741
tandpfun
Featured
tandpfun GitHub avatar

wardrobe

A GPT‑image powered app that extracts individual garment cutouts from photos, organizes them into a digital wardrobe, and generates modeled outfit previews.

JavaScript
1,570
mshumer
Featured
mshumer GitHub avatar

Claude-of-Duty

A browser-based first-person shooter built entirely with procedural generation and orchestrated AI agents, featuring 55k lines of Three.js/WebGL2 code and no art assets.

AI & Machine LearningAI Agents
1,234