spectre.console/docs/input/prompts/multiselection.md
Patrik Svensson 0e0f4b4220 Add interactive prompts for selecting values
* Adds SelectionPrompt
* Adds MultiSelectionPrompt

Closes #210
2021-01-09 09:37:28 +01:00

819 B

Title: Multi Selection Order: 3

The MultiSelectionPrompt can be used when you want the user to select one or many items from a provided list.

Usage

// Ask for the user's favorite fruits
var fruits = AnsiConsole.Prompt(
    new MultiSelectionPrompt<string>()
        .Title("What are your [green]favorite fruits[/]?")
        .NotRequired() // Not required to have a favorite fruit
        .PageSize(10)
        .AddChoice("Apple")
        .AddChoices(new[] {
            "Apricot", "Avocado", 
            "Banana", "Blackcurrant", "Blueberry",
            "Cherry", "Cloudberry", "Cocunut",
        }));

// Write the selected fruits to the terminal
foreach (string fruit in fruits) 
{
    AnsiConsole.WriteLine(fruit);
}