diff --git a/src/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs b/src/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs index 24a3e90b1..5fd4bda62 100644 --- a/src/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs +++ b/src/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs @@ -42,6 +42,23 @@ public static ConfirmationPrompt HideChoices(this ConfirmationPrompt obj) return ShowChoices(obj, false); } + /// + /// Sets the style in which the list of choices is displayed. + /// + /// The confirmation prompt. + /// The style to use for displaying the choices or to use the default style (blue). + /// The same instance so that multiple calls can be chained. + public static ConfirmationPrompt ChoicesStyle(this ConfirmationPrompt obj, Style? style) + { + if (obj is null) + { + throw new ArgumentNullException(nameof(obj)); + } + + obj.ChoicesStyle = style; + return obj; + } + /// /// Show or hide the default value. /// @@ -79,6 +96,23 @@ public static ConfirmationPrompt HideDefaultValue(this ConfirmationPrompt obj) return ShowDefaultValue(obj, false); } + /// + /// Sets the style in which the default value is displayed. + /// + /// The confirmation prompt. + /// The default value style or to use the default style (green). + /// The same instance so that multiple calls can be chained. + public static ConfirmationPrompt DefaultValueStyle(this ConfirmationPrompt obj, Style? style) + { + if (obj is null) + { + throw new ArgumentNullException(nameof(obj)); + } + + obj.DefaultValueStyle = style; + return obj; + } + /// /// Sets the "invalid choice" message for the prompt. /// diff --git a/src/Spectre.Console/Prompts/ConfirmationPrompt.cs b/src/Spectre.Console/Prompts/ConfirmationPrompt.cs index 4909ee2b2..5257d5233 100644 --- a/src/Spectre.Console/Prompts/ConfirmationPrompt.cs +++ b/src/Spectre.Console/Prompts/ConfirmationPrompt.cs @@ -39,6 +39,16 @@ public sealed class ConfirmationPrompt : IPrompt /// public bool ShowDefaultValue { get; set; } = true; + /// + /// Gets or sets the style in which the default value is displayed. Defaults to green when . + /// + public Style? DefaultValueStyle { get; set; } + + /// + /// Gets or sets the style in which the list of choices is displayed. Defaults to blue when . + /// + public Style? ChoicesStyle { get; set; } + /// /// Gets or sets the string comparer to use when comparing user input /// against Yes/No choices. @@ -72,8 +82,10 @@ public async Task ShowAsync(IAnsiConsole console, CancellationToken cancel .InvalidChoiceMessage(InvalidChoiceMessage) .ValidationErrorMessage(InvalidChoiceMessage) .ShowChoices(ShowChoices) + .ChoicesStyle(ChoicesStyle) .ShowDefaultValue(ShowDefaultValue) .DefaultValue(DefaultValue ? Yes : No) + .DefaultValueStyle(DefaultValueStyle) .AddChoice(Yes) .AddChoice(No);