Picker
Description
Picker is a versatile UI component used for selecting items from a list of suggestions. It provides support for both multi-selection (with tag-like selections) and single selection modes, and it can render selected items either inline or as separate components. This component is useful when you need to allow users to search, filter, and pick recipients or tags with confirmation feedback via suggestions.
Usage
You instantiate a Picker using the static helper method from Tesserae.UI. The component is generic (Picker
Below is a simple example demonstrating how to create a picker with text suggestions:
API reference
public sealed class Picker<TPickerItem> : IComponent, ITabIndex, IObservableListComponent<TPickerItem>, IRoundedStyle where TPickerItem : class, IPickerItemA multi-select input that lets the user pick one or more typed items from a dropdown, with optional async loading and free-text entry.
Constructors
Properties
public IEnumerable<TPickerItem> SelectedPickerItemsGets or sets the selected picker items.
public IEnumerable<TPickerItem> UnselectedPickerItemsGets or sets the unselected picker items.
public int? MaximumAllowedSelections { get; }Gets or sets the maximum allowed selections.
public bool DuplicateSelectionsAllowed { get; }Gets or sets the duplicate selections allowed.
Methods
public IObservable<IReadOnlyList<TPickerItem>> AsObservable()Returns the component's state as a(n) observable.
public Picker<TPickerItem> Items(params TPickerItem[] items)Adds the given items to the component.
public Picker<TPickerItem> Items(IEnumerable<TPickerItem> items)Adds the given items to the component.
public Picker<TPickerItem> OnItemSelected(ComponentEventHandler<Picker<TPickerItem>, ItemPickedEvent> eventHandler)Registers a callback invoked when the item selected event fires.
Samples
Basic Picker with Text Suggestions
In this sample, we create a picker that supports multiple selections. We add a few sample items and register an event handler to log the selected item to the console.
Picker with Inline Selections and Component-based Rendering
This sample demonstrates a picker that renders selected items using an icon alongside text for a richer UI experience.