Skip to content
WunderUI

Prompt Mode Switch

Pro

What the agent may do with the next prompt: answer, act or edit. Three modes in one pill switch, a line about the chosen one and the keys that send.

Playground

Answers questions. Changes nothing.

↵ to send ⇧↵ for a new line

Installation

Prompt Mode Switch comes with WunderUI Core and Pro, in the package from your plan. See the plans.

Then import what you need:

tsx
import { PromptModeSwitch } from "@wunderui/react"

Then use it:

tsx
import { useState } from "react"
import { PromptModeSwitch } from "@wunderui/react"

export function Composer() {
  const [mode, setMode] = useState<"ask" | "agent" | "edit">("ask")

  return <PromptModeSwitch value={mode} onValueChange={setMode} />
}

Expected result: You should see a pill switch with Ask pressed, the line Answers questions, and the send keys underneath. Press Agent and the line changes to Plans and runs tools.

When to use

Use Prompt Mode Switch for

  • A prompt box where the same text can only answer, run tools or edit files
  • A chat or an agent with a safe default and a person who widens its reach on purpose
  • Any place where the consequence of a prompt depends on a choice made before it is sent

Use something else for

  • Model Picker for choosing which model answers
  • Model Select for choosing the model and how hard it thinks, with its price
  • Tool Permission Row for a lasting Allow, Ask or Deny setting for one tool
  • Segment for a switch with your own options, labels and icons

Mode

The mode is a promise about the next prompt. The switch only reports it; the rule is your app's, and the text should say in plain words what the agent may do.

Answers questions. Changes nothing.

↵ to send ⇧↵ for a new line

Read project files
Yes
Run tools
No
Change files
No

Hints

The line under the switch follows the chosen mode and is read out when it changes. Replace all three lines with your own, or hide the send keys.

Plans and runs tools. Asks before risky steps.

↵ to send ⇧↵ for a new line

Control

Uncontrolled, the switch keeps the mode. Controlled, your value wins: a switch whose value you do not change stays put, which is how an app refuses a mode.

Plans and runs tools. Asks before risky steps.

↵ to send ⇧↵ for a new line

The switch keeps the mode itself. Your code never hears of it.

Keyboard interactions

The three options are a tab group: one tab stop, and the arrow keys move inside it.

TaborShiftTab
Moves focus into the group on the pressed option and out of it again. The two other options are skipped.
→or←
Moves focus to the next or previous option and selects it at once, so is called on every press. After Edit comes Ask, and before Ask comes Edit.
HomeorEnd
Moves focus to the first option (Ask) or the last (Edit) and selects it.
EnterorSpace
Presses the focused option. On the pressed option nothing changes.

The options are tabs, so a screen reader says tab and selected, not radio button. Up and Down do nothing, and a disabled mode does not exist.

Behavior and motion

What the switch does with the mode, the hint and the keys, and what it leaves to you.

Selection follows focus
An arrow key moves focus and selects in one step, and the change handler is called each time, so a key press that only passes Agent still reports Agent. Read the mode when the prompt is sent.
It only reports
The switch does not stop a run, ask for a confirmation or store the mode. What a mode lets the agent do is your rule; show it in words near the switch.
Controlled or not
Pass a value and the switch shows exactly that; if your state does not change, the pressed option does not move. Without a value the switch keeps the mode itself, starting at ask.
The hint
The line under the switch is a polite live region, so a change is read out. Custom hints replace all three lines and need a text for every mode.
The send keys
The two key hints are plain text: the switch does not listen to Enter, Prompt Input does. Turn the line off where the box sends differently.
Three fixed modes
The options are Ask, Agent and Edit. You cannot hide, disable, rename or add a mode, and there are no icons.
Failure: a mode that is not allowed
A mode cannot be disabled, so in the handler keep the old value, show the reason next to the switch with an Alert and offer the fix. The Examples tab shows Agent without a connected workspace.
Layout
A column that aligns to the start: switch, hint, send keys. The hint and the keys wrap on a narrow screen; the switch keeps its width.
Motion
The options change colour quickly and nothing slides: the pressed pill appears in place. Nothing else moves.
Reduced motion
With reduced motion the colour change still runs; there is no transform to remove.

Anatomy

The figure marks the whole component with the Agent mode pressed. The three options are one part; the hint and the send keys are the two lines underneath.

Plans and runs tools. Asks before risky steps.

↵ to send ⇧↵ for a new line

  • data-slot="prompt-mode-switch"

    A column with an 8 px gap that carries the chosen mode (ask, agent or edit), which you can style or test against. Beside its own props it takes only a class name.

  • The pill switch: a small segmented control named Prompt mode, with the options Ask, Agent and Edit. It is a tab list, so a screen reader announces three tabs, not radio buttons.

  • The pressed option: a white pill marked selected, and the only tab stop of the group. The other two are reached with Arrow keys.

  • One 12 px line about the chosen mode, in a polite live region so a change is read out. It comes from the hints and is always shown.

  • Optional

    A line of text with two Kbd badges: ↵ to send and ⇧↵ for a new line. It is a legend only and the switch does not listen to Enter, so you can hide it.

Best practices

  • Do

    Read the mode when the prompt is sent, not in the change handler. Arrow keys select at every step, so a keyboard user passes through Agent on the way from Ask to Edit.

  • Do

    Write each hint as the consequence, not the label: Edits the selected files in place tells a person what will happen, Edit mode does not.

  • Do

    Keep ask as the default. The mode with the least reach is the safe one to start in; a person widens it on purpose.

  • Do

    Show the mode where the run is shown (for example next to Agent Status), so the mode a run started in is still visible once the switch has moved on.

  • Do

    When a mode is not allowed, keep the old value, say why next to the switch and offer the way out, such as connecting a workspace. The switch has no disabled option.

  • Don’t

    Don't let a change of the switch stop, restart or re-plan a run that is going. It applies to the next prompt; say so in a line of text.

  • Don’t

    Don't start an agent, send a request or delete anything in the change handler. A key press that is only passing through can call it.

  • Don’t

    Don't rely on the look of the pressed option alone. The state is exposed as selected and the hint names the mode in words.

API reference

PromptModeSwitch is a plain component, not a wrapper of a primitive, so this table lists every prop.

A column with an 8 px gap that carries the chosen mode (ask, agent or edit), which you can style or test against. Beside its own props it takes only a class name.

PropTypeDefaultDescription
value"edit" | "agent" | "ask"—The mode that is pressed, for a controlled switch: , or . If you do not change it in , the switch stays where it was.
defaultValue"edit" | "agent" | "ask""ask"The mode that starts pressed when you do not pass . by default.
onValueChange(mode) => void—Called with the new mode on every click and every arrow key, also when the key only passes the mode. Read the mode when the prompt is sent, not here.
hintsRecord<PromptMode, string>MODE_HINTThe line under the switch for each mode, as . All three keys are needed. The default lines are , and
showKeysbooleantrueShows the line . by default. It is text only.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("prompt-mode-switch")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.