SelectionPrompt<T> Class

Represents a single list prompt.
public sealed class SelectionPrompt<T> : IPrompt<T>, IListPromptStrategy<T> where T : notnull
Namespace
Spectre.Console
Interfaces

Parameters

T
The prompt result type.

Constructors

SelectionPrompt()
Initializes a new instance of the SelectionPrompt<T> class.

Properties

Func<T, string> Converter
Gets or sets the converter to get the display string for a choice. By default the corresponding TypeConverter is used.
Style DisabledStyle
Gets or sets the style of a disabled choice.
Style HighlightStyle
Gets or sets the highlight style of the selected choice.
SelectionMode Mode
Gets or sets the selection mode. Defaults to Leaf.
string MoreChoicesText
Gets or sets the text that will be displayed if there are more choices to show.
int PageSize
Gets or sets the page size. Defaults to 10.
string Title
Gets or sets the title.

Methods

ISelectionItem<T> AddChoice(T)
Adds a choice.
T Show(IAnsiConsole)
Shows the prompt.
Task<T> ShowAsync(IAnsiConsole, CancellationToken)
Shows the prompt asynchronously.

Extension Methods

SelectionPrompt<T> AddChoiceGroup<T>(T, IEnumerable<T>)
Adds multiple grouped choices.
SelectionPrompt<T> AddChoiceGroup<T>(T, T[])
Adds multiple grouped choices.
SelectionPrompt<T> AddChoices<T>(IEnumerable<T>)
Adds multiple choices.
SelectionPrompt<T> AddChoices<T>(T[])
Adds multiple choices.
SelectionPrompt<T> HighlightStyle<T>(Style)
Sets the highlight style of the selected choice.
SelectionPrompt<T> Mode<T>(SelectionMode)
Sets the selection mode.
SelectionPrompt<T> MoreChoicesText<T>(string)
Sets the text that will be displayed if there are more choices to show.
SelectionPrompt<T> PageSize<T>(int)
Sets how many choices that are displayed to the user.
SelectionPrompt<T> Title<T>(string)
Sets the title.
SelectionPrompt<T> UseConverter<T>(Func<T, string>)
Sets the function to create a display string for a given choice.