mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 10:35:27 +08:00 
			
		
		
		
	Add interactive prompts for selecting values
* Adds SelectionPrompt * Adds MultiSelectionPrompt Closes #210
This commit is contained in:
		
				
					committed by
					
						
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						parent
						
							3a593857c8
						
					
				
				
					commit
					0e0f4b4220
				
			
							
								
								
									
										27
									
								
								docs/input/prompts/selection.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								docs/input/prompts/selection.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
Title: Selection
 | 
			
		||||
Order: 1
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
The `SelectionPrompt` can be used when you want the user to select
 | 
			
		||||
a single item from a provided list.
 | 
			
		||||
 | 
			
		||||
<img src="../assets/images/selection.gif" style="width: 100%;" />
 | 
			
		||||
 | 
			
		||||
# Usage
 | 
			
		||||
 | 
			
		||||
```csharp
 | 
			
		||||
// Ask for the user's favorite fruit
 | 
			
		||||
var fruit = AnsiConsole.Prompt(
 | 
			
		||||
    new SelectionPrompt<string>()
 | 
			
		||||
        .Title("What's your [green]favorite fruit[/]?")
 | 
			
		||||
        .PageSize(10)
 | 
			
		||||
        .AddChoice("Apple")
 | 
			
		||||
        .AddChoices(new[] {
 | 
			
		||||
            "Apricot", "Avocado", 
 | 
			
		||||
            "Banana", "Blackcurrant", "Blueberry",
 | 
			
		||||
            "Cherry", "Cloudberry", "Cocunut",
 | 
			
		||||
        }));
 | 
			
		||||
 | 
			
		||||
// Echo the fruit back to the terminal
 | 
			
		||||
AnsiConsole.WriteLine($"I agree. {fruit} is tasty!");
 | 
			
		||||
```
 | 
			
		||||
		Reference in New Issue
	
	Block a user