← Back to Home • Next: Switch — Styles →
How the Switch control behaves while it is running: keyboard, the two labeled states, history, and
the details that matter in real apps.
Enable feature? ← prompt
Notifications are enabled ← description (optional / dynamic)
Yes No ← the two states; the active one is highlighted
Left/Right / Space: toggle Enter Esc ← tooltip (toggle with F1 / Ctrl+F1)
OnValue /
OffValue, or the localized Yes/No text when you do not override them.SwitchOn / SwitchOff style regions.Every region can be recolored — see Styles.
| Key | Action |
|---|---|
← |
Force the state to off, regardless of the current state |
→ |
Force the state to on, regardless of the current state |
Space |
Toggle — flips the current state to its opposite |
Enter |
Confirm — returns the current state |
Esc |
Abort (when the abort key is enabled) → IsAborted == true, Content == null |
F1 |
Cycle tooltip content |
Ctrl+F1 |
Show / hide the tooltip |
⚠️
←/→are absolute, not relative —←always lands on off and→always lands on on, even if you’re already there. OnlySpaceactually flips the current value. There is also noTab/Shift+Tabbinding on this control.
true) or off (false).Default(bool); it starts off if you do
not.OnValue / OffValue.
The emoji overloads render an emoji with a plain-text fallback for terminals that cannot display
it. Without overrides, the labels are the localized Yes/No text (not literal ON/OFF).ChangeDescription updates the description line as the state
flips — handy to spell out the consequence of each state.When EnableHistory(filename, …) is set:
filename.Default(value, useDefaultHistory: true), the last saved state is
pre-loaded as the starting state instead of value.IHistoryOptions (expiration, max items, and so on) governs what is retained.You can also manage a history store directly with PromptPlus.Controls.History(filename) — add,
save, or remove entries programmatically (used in the samples to seed reproducible data).
Set per instance via Options(...), or globally on
PromptPlus.Config:
| Option | Effect on Switch |
|---|---|
EnabledAbortKey(false) |
Removes Esc — the user must confirm |
HideAfterFinish(true) |
Erases the toggle after confirm — the whole control is erased, not just the interactive part |
HideOnAbort(true) |
Erases the toggle after Esc |
ShowTooltip(false) |
Hides the keyboard hint line |
Description(...) |
Overrides the description text |
The global
PromptPlus.Config.SwitchWidthinfluences how the toggle is laid out.
Content == null, not the seeded Default. Always branch on
IsAborted before reading the value; because Content is bool?, compare with == true to be
explicit.OnValue / OffValue, the plain-text fallback is
shown instead.Options, SwitchWidth