Tesserae

ObservableStack

Description

ObservableStack is a container component that manages the display of its child components using a flexbox-inspired layout and an efficient reconciliation process. It leverages an observable list of components (each implementing an identifier and content hash) to update only those parts of the DOM that have changed, improving performance in dynamic interfaces. This component is part of the Collections group and is ideal for scenarios where the UI state, such as scroll position, must be maintained with minimal re-rendering.

Usage

Create an ObservableStack by supplying an ObservableList of components that implement IComponentWithID. The component can be configured for different orientations (vertical, horizontal, etc.) and debounced updates if needed.

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.

Constructors

Constructor
ObservableStack
public ObservableStack(ObservableList<IComponentWithID> observableList, Orientation orientation = Orientation.Vertical, bool debounce = true)

Initializes a new instance of this class.

Properties

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

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

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

Referenced by

© 2026 Tesserae. All rights reserved.