ObservableStack

Description

ObservableStack<T> renders a list of items into a host Stack and keeps it in sync with an observable source. On every change it reconciles the DOM in place — only inserted, removed, or moved rows are touched — so scroll position and focus on the surrounding rows are preserved. This makes it suited to dynamic lists where re-rendering the whole stack would be wasteful or disruptive.

Usage

Create an ObservableStack<T> by supplying an IObservable<IReadOnlyList<T>> source and a renderItem delegate that builds a component for each item. ObservableList<T> implements that interface, so it can be passed directly; mutating the list (Add, RemoveAt, ReplaceAll, …) drives the reconciliation. An optional host Stack lets you control orientation and layout (defaults to a vertical Stack).

API reference

class

ObservableStack

public class ObservableStack : IComponent, IHasBackgroundColor, IHasMarginPadding, ISpecialCaseStyling, ICanWrap

A Stack is a container-type component that abstracts the implementation of a flexbox in order to define the layout of its children components.

Namespace
Tesserae
Implements
IComponent, IHasBackgroundColor, IHasMarginPadding, ISpecialCaseStyling, ICanWrap

Constructors

NameDescription
ObservableStackInitializes a new instance of this class.
Constructor
ObservableStack
public ObservableStack(ObservableList<IComponentWithID> observableList, Orientation orientation = Orientation.Vertical, bool debounce = true)

Initializes a new instance of this class.

Properties

NameDescription
StackOrientationGets or sets the stack orientation.
CanWrapGets or sets a value indicating whether the component's text can wrap onto multiple lines.
IsInlineReturns a value indicating whether the component is inline.
InnerElementGets the underlying DOM element backing this component.
BackgroundGets or sets the CSS background of the component.
MarginGets or sets the CSS margin of the component.
PaddingGets or sets the CSS padding of the component.
StylingContainerGets or sets the styling container.
PropagateToStackItemParentGets or sets the propagate to stack item parent.
Property
ObservableStack.StackOrientation
public Orientation StackOrientation { get ; set ; }

Gets or sets the stack orientation.

Property
ObservableStack.CanWrap
public bool CanWrap { get ; set ; }

Gets or sets a value indicating whether the component's text can wrap onto multiple lines.

Property
ObservableStack.IsInline
public bool IsInline { get ; set ; }

Returns a value indicating whether the component is inline.

Property
ObservableStack.InnerElement
public HTMLElement InnerElement { get; private set; }

Gets the underlying DOM element backing this component.

Property
ObservableStack.Background
public string Background { get ; set ; }

Gets or sets the CSS background of the component.

Property
ObservableStack.Margin
public string Margin { get ; set ; }

Gets or sets the CSS margin of the component.

Property
ObservableStack.Padding
public string Padding { get ; set ; }

Gets or sets the CSS padding of the component.

Property
ObservableStack.StylingContainer
public HTMLElement StylingContainer

Gets or sets the styling container.

Property
ObservableStack.PropagateToStackItemParent
public bool PropagateToStackItemParent { get; private set; }

Gets or sets the propagate to stack item parent.

Methods

NameDescription
AlignItemsSets the align-items css property for this stack
AlignItemsCenterSets the align-items css property for this stack to 'center'
RelativeMake this stack relative (i.e. position:relative)
AlignContentSets the align-content CSS property for this stack.
JustifyContentSets the justify-content CSS property for this stack.
JustifyItemsSets the justify-items CSS property for this stack.
RemovePropagationRemoves the given propagation from the component.
OnMouseOverRegisters a callback invoked when the mouse over event fires.
OnMouseOutRegisters a callback invoked when the mouse out event fires.
ClearClears the component's current state.
RenderRenders the component's root HTML element.
HorizontalConfigures the component to horizontal.
VerticalConfigures the component to vertical.
HorizontalReverseConfigures the horizontal reverse on the component.
VerticalReverseConfigures the vertical reverse on the component.
WrapAllows the component's content to wrap onto multiple lines.
InlineRenders the component inline.
NoWrapRemoves / disables the wrap on the component.
OverflowHiddenHides any content that overflows the component's bounds.
NoDefaultMarginRemoves / disables the default margin on the component.
SkeletonConfigures the component to skeleton.
Method
ObservableStack.AlignItems
public ObservableStack AlignItems(ItemAlign align)

Sets the align-items css property for this stack

Parameters

align
Method
ObservableStack.AlignItemsCenter
public ObservableStack AlignItemsCenter()

Sets the align-items css property for this stack to 'center'

Parameters

align
Method
ObservableStack.Relative
public ObservableStack Relative()

Make this stack relative (i.e. position:relative)

Method
ObservableStack.AlignContent
public ObservableStack AlignContent(ItemAlign align)

Sets the align-content CSS property for this stack.

Parameters

align
The alignment.

Returns

The current instance.

Method
ObservableStack.JustifyContent
public ObservableStack JustifyContent(ItemJustify justify)

Sets the justify-content CSS property for this stack.

Parameters

justify
The justification.

Returns

The current instance.

Method
ObservableStack.JustifyItems
public ObservableStack JustifyItems(ItemJustify justify)

Sets the justify-items CSS property for this stack.

Parameters

justify
The justification.

Returns

The current instance.

Method
ObservableStack.RemovePropagation
public ObservableStack RemovePropagation()

Removes the given propagation from the component.

Method
ObservableStack.OnMouseOver
public ObservableStack OnMouseOver(ComponentEventHandler<ObservableStack, Event> onMouseOver)

Registers a callback invoked when the mouse over event fires.

Method
ObservableStack.OnMouseOut
public ObservableStack OnMouseOut(ComponentEventHandler<ObservableStack, Event> onMouseOut)

Registers a callback invoked when the mouse out event fires.

Method
ObservableStack.Clear
public virtual void Clear()

Clears the component's current state.

Method
ObservableStack.Render
public virtual HTMLElement Render()

Renders the component's root HTML element.

Method
ObservableStack.Horizontal
public ObservableStack Horizontal()

Configures the component to horizontal.

Method
ObservableStack.Vertical
public ObservableStack Vertical()

Configures the component to vertical.

Method
ObservableStack.HorizontalReverse
public ObservableStack HorizontalReverse()

Configures the horizontal reverse on the component.

Method
ObservableStack.VerticalReverse
public ObservableStack VerticalReverse()

Configures the vertical reverse on the component.

Method
ObservableStack.Wrap
public ObservableStack Wrap()

Allows the component's content to wrap onto multiple lines.

Method
ObservableStack.Inline
public ObservableStack Inline()

Renders the component inline.

Method
ObservableStack.NoWrap
public ObservableStack NoWrap()

Removes / disables the wrap on the component.

Method
ObservableStack.OverflowHidden
public ObservableStack OverflowHidden()

Hides any content that overflows the component's bounds.

Method
ObservableStack.NoDefaultMargin
public ObservableStack NoDefaultMargin()

Removes / disables the default margin on the component.

Method
ObservableStack.Skeleton
public IComponent Skeleton(bool enabled = true)

Configures the component to skeleton.

interface

IComponentWithID

public interface IComponentWithID : IComponent
Namespace
Tesserae
Implements
IComponent

Samples

Basic ObservableStack Usage

The following sample demonstrates how to set up an ObservableStack, attach it to an observable list of components, and render it.

See Also

© 2026 Curiosity. All rights reserved.