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.
bool SearchEnabled
Gets or sets a value indicating whether or not search is enabled.
Style SearchHighlightStyle
Gets or sets the style of highlighted search matches.
string SearchPlaceholderText
Gets or sets the text that will be displayed when no search text has been entered.
string Title
Gets or sets the title.
bool WrapAround
Gets or sets a value indicating whether the selection should wrap around when reaching the edge. Defaults to false.

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> DisableSearch<T>()
Disables search for the prompt.
SelectionPrompt<T> EnableSearch<T>()
Enables search for the prompt.
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> SearchPlaceholderText<T>(string)
Sets the text that will be displayed when no search text has been entered.
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.
SelectionPrompt<T> WrapAround<T>(bool)
Sets whether the selection should wrap around when reaching its edges.