← Back to Home • Next: MaskEdit Control →
The Secret (and Input) control paints its output in named regions. Each
region is an InputStyles value you can recolor per control instance.
ℹ️ Styling is per control — there is no global “style all secrets” API. Set styles on each control (or through a small helper you reuse). The only style-related global setting is
PromptPlus.Config.ContrastRatio.
InputStyles regionsSecret shares the InputStyles enum with Input. Some regions (suggestion, pagination) never
appear because Secret has no autocomplete or history, but the enum values are still valid.
| Region | What it paints |
|---|---|
Prompt |
The prompt text |
Answer |
The masked value being typed / the confirmed answer |
Description |
The description line under the prompt |
Suggestion |
Autocomplete suggestion text (not used by Secret) |
Selected |
The highlighted list entry (not used by Secret) |
UnSelected |
Non-highlighted list entries (not used by Secret) |
Error |
The validation error line |
Pagination |
The page indicator during list navigation (not used by Secret) |
Tooltips |
The keyboard-hint line |
Use the fluent Styles method. A Style is a foreground color, a background
color, and an Overflow strategy — there is no bold/italic/underline. A bare Color is accepted
as shorthand for a foreground-only style.
using ConsolePlusLibrary;
using PromptPlusLibrary;
PromptPlus.Controls
.Secret("PIN")
.Styles(InputStyles.Answer, Color.Green) // Color shorthand (foreground)
.Styles(InputStyles.Error, new Style(Color.Red, Color.Default)) // explicit fg + bg
.Run();
To reuse a theme across secret fields, wrap the styling in a helper you call for each control — the library does not broadcast styles for you. See Global Styles for the pattern.
PromptPlus nudges foreground colors that fall below the configured contrast ratio so text stays readable on any terminal theme. Tune or disable with:
PromptPlus.Config.ContrastRatio = 0; // disable
PromptPlus.Config.ContrastRatio = 4.5; // WCAG AA target
Style type, per-control styling, contrastStyle API and Overflow