← Back to Home • Next: MultiSelect — Methods →
A scrollable, filterable list of checkboxes where the user checks several items with Space and confirms the whole set with Enter.
MultiSelect<T> is the multiple-choice sibling of Select<T>: same list model,
same grouping, filtering, and paging — but each row carries a checkbox and .Run() returns the whole
array of checked items. It works with strings, enums, records, or your own types; it can group
items under headers, filter as the user types, enforce a minimum/maximum number of picks, show extra
info per row, and validate each check before it is accepted.
🔘 Need to pick exactly one item? Use the Select control — same list model, single answer.
| Sub-page | What you will find |
|---|---|
| Index (this page) | What it is, when to use it, first examples, the method map |
| Methods | Every fluent method — signature, parameters, defaults, and a snippet |
| Operations | Keyboard, checking, filtering, grouping, range, validation, history, view-only |
| Styles | The MultiSelectStyles regions and how to recolor them |
Use MultiSelect<T> when… |
Consider instead… |
|---|---|
| The user checks several options from a known set | — |
| The user picks exactly one option | Select |
| The data is tabular (multiple columns) | TableSelect |
| The data is hierarchical | TreeSelect |
| It is a yes/no or single-key answer | KeyPress / Confirm |
using PromptPlusLibrary;
var result = PromptPlus.Controls
.MultiSelect<string>("Pick your toppings")
.AddItems(["Cheese", "Mushrooms", "Onions", "Peppers"])
.Run();
if (!result.IsAborted)
PromptPlus.Console.WriteLine($"You chose: {string.Join(", ", result.Content)}");
MultiSelect<string>("Pick your toppings") creates a checkbox list of strings. The type argument
T is the item type..AddItems([...]) fills the list; .AddItem(x) adds one at a time (and can pre-check it)..Run() renders the list and blocks until Enter (confirm) or Esc (abort), returning a
ResultPrompt<T[]> — the array of checked items.MultiSelect<T> reads enum members automatically — including [Display(Name = ..., Order = ...)]
attributes for the label and ordering. No AddItems call needed:
enum Feature { Logging, Caching, Metrics, Tracing }
var features = PromptPlus.Controls.MultiSelect<Feature>("Enable features").Run();
using PromptPlusLibrary;
var cities = PromptPlus.Controls
.MultiSelect<string>("Which cities?", "Type to filter")
.AddGroupedItems("North America", ["Seattle", "Boston", "New York"])
.AddGroupedItems("Asia", ["Tokyo", "Singapore", "Shanghai"])
.Filter(FilterMode.Contains) // live filtering as the user types
.Range(1, 3) // at least 1, at most 3
.PageSize(5) // 5 rows visible at a time
.Run();
This combines grouping (headers), filtering, paging, and a selection range — see Operations for how they behave together.
Grouped by purpose. Full signatures and examples are on the Methods page.
| Purpose | Methods |
|---|---|
| Add items | AddItem, AddItems, AddGroupedItem, AddGroupedItems, AddSeparator |
| Load from a source | Interaction, InteractionAsync |
| Item text & info | TextSelector, TextSelectorAsync, ExtraInfo, ExtraInfoAsync, HideTipGroup |
| Filtering & paging | Filter, PageSize |
| Initial value | Default, UseDefaultHistory, DefaultMatchBy |
| Selection range | Range |
| Validate each check | PredicateChecked, PredicateCheckedAsync |
| Read-only display | ViewOnly |
| Dynamic description | ChangeDescription, ChangeDescriptionAsync |
| History | EnableHistory |
| Appearance & behavior | Styles, Options |
| Run | Run |
MultiSelect<T> returns ResultPrompt<T[]> — the array of checked items.
| Member | Meaning |
|---|---|
.Content |
The checked items as a T[] (an empty array if aborted or nothing checked) |
.IsAborted |
true when the user pressed Esc |
var (picked, aborted) = PromptPlus.Controls
.MultiSelect<string>("Toppings").AddItems(["Cheese", "Onions"]).Run();
if (!aborted)
PromptPlus.Console.WriteLine($"{picked.Length} selected");
Unlike
Select<T>(which returns a singleT),MultiSelect<T>always returns an array — nevernull. Check.Content.Lengthto tell “confirmed nothing” from a real pick.