Timeline
Description
The Timeline component provides a base for rendering vertical timelines. It arranges timeline items and alternates their placement (left/right) by default, but it also supports layout adjustments such as rendering all items on the same side or constraining the timeline width. Use this component when you need to visually represent events or steps in a vertical sequence in your UI.
Usage
Instantiate the Timeline component using the fluent interface provided by Tesserae.UI. You can add timeline items, adjust the timeline's maximum width, or force the timeline to render all items on the same side using the available methods.
Below is a minimal example showing how to create a simple Timeline with several text items:
API reference
public class Timeline : IContainer<Timeline, IComponent>, IHasBackgroundColor, IHasMarginPaddingA Timeline component that displays events in chronological order.
Properties
public string Background { get ; set ; }Gets or sets the background color of the timeline.
public string Padding { get ; set ; }Gets or sets the padding of the timeline.
Methods
public void Add(IComponent component)Adds a component to the timeline.
Parameters
- component
- The component to add.
public void Add(IComponent component, string color)Adds a component to the timeline with a specified color.
Parameters
- component
- The component to add.
- color
- The color of the timeline circle.
public Timeline SameSide()Sets the timeline to display items on the same side.
Returns
The current instance of the type.
public Timeline SameSideIf(int minWidthPixels)Sets the timeline to display items on the same side if the width is less than the specified minimum width.
Parameters
- minWidthPixels
- The minimum width in pixels.
Returns
The current instance of the type.
public Timeline TimelineWidth(UnitSize maxWidth)Sets the maximum width of the timeline.
Parameters
- maxWidth
- The maximum width.
Returns
The current instance of the type.
public HTMLElement Render()Renders the timeline.
Returns
The rendered HTMLElement.
Samples
Basic Timeline with Alternating Items
This sample creates a timeline with alternating left/right positioned items. It adds five text items to the timeline.
Timeline with Custom Width and Same Side Layout
This sample demonstrates how to set a custom maximum width and force the timeline items to render on the same side.