ItemsList
Description
ItemsList is a flexible list component designed for displaying small sets of items. It belongs to the Collections group and can render items in different layouts depending on the specified columns. When provided with multiple columns, it renders the items using a grid layout; if fewer than two columns are provided, it falls back to a horizontal stack layout. This component is ideal for scenarios where you want to display items without the overhead of virtualization, and it supports customizing the message shown when the list is empty.
Usage
The ItemsList component can be instantiated using the static helper methods provided by the Tesserae.UI class. It accepts either an array of IComponent items or an ObservableList
Below is a basic example of how to create an ItemsList:
API reference
public sealed class ItemsList : IComponent, ISpecialCaseStylingA simple, non-virtualised vertical list of arbitrary items, used when a DetailsList{T} would be overkill.
- Namespace
- Tesserae
- Implements
- IComponent, ISpecialCaseStyling
Constructors
| Name | Description |
|---|---|
| ItemsList | Initializes a new instance of this class. |
| Overload | |
|---|---|
| ItemsList(IComponent[], UnitSize[]) | Initializes a new instance of this class. |
| ItemsList(ObservableList<IComponent>, UnitSize[]) | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| Items | Adds the given items to the component. |
| StylingContainer | Gets or sets the styling container. |
| PropagateStylesToWrapper | Gets whether a sizing helper applied to this component should tag it so a wrapper-building container hoists the style onto the wrapper. |
public ObservableList<IComponent> Items { get; }Adds the given items to the component.
public HTMLElement StylingContainerGets or sets the styling container.
Methods
| Name | Description |
|---|---|
| WithEmptyMessage | Returns the component configured with the given empty message. |
| Render | Renders the component's root HTML element. |
public ItemsList WithEmptyMessage(Func<IComponent> emptyListMessageGenerator)Returns the component configured with the given empty message.
Samples
Basic ItemsList with Single Column
This sample renders 12 cards stacked vertically. With a single column width (100%) ItemsList uses a stack layout; the container scrolls when the items exceed the visible area.
Multi-column Grid Layout with Varied Widths
Passing multiple column widths switches the layout to a grid. Mixing fixed and fractional widths shows how ItemsList handles responsive sizing.
Empty-state Customization
When the list contains no items, WithEmptyMessage controls the placeholder. The delegate is rendered inline so it can include any Tesserae component, including action buttons.
See Also
- VirtualizedList – For handling larger sets of items efficiently.
- Grid – Related layout component used in multi-column scenarios.
- Stack – Alternative layout when using a single column display.