Mode switcher
Fast, Thinking, Research: a segmented switch with a sliding pill and locked paid modes.
Used forAI chat appsPlan-gated featuresSearch and assistantsSettings with a few options
Part of AI chat components for React, the parts of a chat in the order they appear.
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/mode-switcher. Set it up
Templates
Need the whole page?
63 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
AI chat apps
Choose between Fast, Thinking and Research.
Plan-gated features
Show paid modes with a lock so people see what an upgrade unlocks.
Search and assistants
A quick or deep mode for the same question box.
Settings with a few options
Any choice of two to four exclusive modes, such as view or editor modes.
What it handles for you
People should be able to choose how a model works without reading a spec sheet. This is a small segmented switch that says what each mode does and shows what an upgrade would unlock.
A pill thrown to the choice
The pill slides to the chosen mode with a little give, and its width eases to fit.
A line that says what it does
Turn on showDescription and a line underneath morphs to describe the chosen mode.
Paid modes stay visible
Locked modes show a lock. Choosing one calls onLockedSelect, for example to open pricing.
A real radio group
Tab lands on the chosen mode, arrow keys move and skip locked modes.
Controlled or not
Pass value and onValueChange, or let it keep its own selection.
Resizes cleanly
The pill re-measures on resize, and its first placement never animates.
Overview
Lets people choose how the model should work. A pill is thrown to the chosen mode with a little give, an optional line underneath morphs to say what that mode does, and paid modes stay visible with a lock so people can see what an upgrade unlocks. It’s a real radio group: arrow keys move between modes.
States
- selected
- The pill is thrown to the chosen mode with a slight overshoot (460ms) while its width eases; the description below, if enabled, morphs into the new mode’s line, keeping the words they share.
- locked
- Visible with a lock; choosing it calls onLockedSelect (e.g. open pricing) instead of switching.
Usage
Depends on lucide-react, installed for you by the CLI along with the keyframes it needs.
Works with
With the AI SDK
Map the Vercel AI SDK’s message parts and chat status onto the component’s props.
Props
- modes
- { value; label; description?; icon?; locked? }[]
- The modes, in order.
- value / defaultValue / onValueChange
- string
- Controlled or uncontrolled selection.
- onLockedSelect
- (mode) => void
- Called when someone picks a locked mode.
- showDescription= false
- boolean
- Show the chosen mode’s description underneath.
- label= "Mode"
- string
- Accessible name of the radio group.
Accessibility and motion
- role="radiogroup" with roving focus: Tab lands on the chosen mode, arrow keys move and skip locked modes.
- Locked modes are aria-disabled but still focusable and explained in their title.
- The pill re-measures on resize and its first placement never animates. Installs Text morph; with reduced motion the pill jumps and the description changes in place.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Text morph.
Source
Registry item: /r/mode-switcher.json


