Phil Scott c2da268129
Docs redesign (#728)
* Adding a dark mode
* Adding reference for types to summary pages
* Adding API Reference
* Adding modifiers to methods/fields/etc
* Minimizing files input
* Caching a lot of the output pages
* Cache only for each execution
* Adding API references to existing docs
2022-02-14 18:44:25 +01:00

1.1 KiB

Title: Selection Order: 1 Description: "The SelectionPrompt can be used when you want the user to select a single item from a provided list." Reference: - T:Spectre.Console.SelectionPrompt`1 - M:Spectre.Console.AnsiConsole.Prompt1(Spectre.Console.IPrompt{0})

The SelectionPrompt can be used when you want the user to select a single item from a provided list.

Using prompts inside status or progress displays, are not supported.

Usage

// Ask for the user's favorite fruit
var fruit = AnsiConsole.Prompt(
    new SelectionPrompt<string>()
        .Title("What's your [green]favorite fruit[/]?")
        .PageSize(10)
        .MoreChoicesText("[grey](Move up and down to reveal more fruits)[/]")
        .AddChoices(new[] {
            "Apple", "Apricot", "Avocado", 
            "Banana", "Blackcurrant", "Blueberry",
            "Cherry", "Cloudberry", "Cocunut",
        }));

// Echo the fruit back to the terminal
AnsiConsole.WriteLine($"I agree. {fruit} is tasty!");