Pivot
Description
The Pivot component is a tab-based container used to organize and display content panels within a user interface. It allows users to switch between different views or sections by clicking on tab titles, with options to customize tab alignment (normal, justified, or centered) and to control caching of tab content. Use it when you need to present segmented information in a compact, navigable format.
Usage
Instantiate the Pivot component using the static helper method from the Tesserae.UI static class. Add tabs by chaining the .Pivot() method with a unique tab identifier, a title generated with PivotTitle(), and a function that returns the tab content. The Pivot component is designed to be highly configurable with additional style methods for layout management.
Below is a simple usage example:
API reference
public sealed class Pivot : IComponent, ISpecialCaseStylingA horizontal tabbed surface with one tab visible at a time.
- Namespace
- Tesserae
- Implements
- IComponent, ISpecialCaseStyling
Constructors
| Name | Description |
|---|---|
| Pivot | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| SelectedTab | Gets or sets the selected tab. |
| StylingContainer | Gets or sets the styling container. |
| PropagateToStackItemParent | Gets or sets the propagate to stack item parent. |
public HTMLElement StylingContainer { get; }Gets or sets the styling container.
Methods
| Name | Description |
|---|---|
| Justified | Configures the component to justified. |
| Centered | Configures the component to centered. |
| HideIfSingle | Hides the if single. |
| EnableCtrlTabSwitching | Enables Ctrl+Alt+Right / Ctrl+Alt+Left to cycle through tabs in order while the pivot is mounted and focus is inside its container (or no element is focused). Safe to call multiple times — the handler is only registered once. |
| RefreshPivotSizes | Refreshes the pivot sizes. |
| RemoveTab | Removes the given tab from the component. |
| OnBeforeNavigate | Registers a callback invoked when the before navigate event fires. |
| OnNavigate | Registers a callback invoked when the navigate event fires. |
| Select | Configures the component to select. |
| Render | Renders the component's root HTML element. |
public Pivot EnableCtrlTabSwitching()Enables Ctrl+Alt+Right / Ctrl+Alt+Left to cycle through tabs in order while the pivot is mounted and focus is inside its container (or no element is focused). Safe to call multiple times — the handler is only registered once.
public Pivot Select(string id, bool refresh = false)Configures the component to select.
Samples
Basic Pivot Usage Sample
This sample demonstrates creating a basic Pivot with three tabs. It sets up the Pivot, adds tabs with simple text content, applies centered tab alignment, and renders the component to the document body.
Advanced Usage: Cached vs. Not Cached Tabs
This sample shows how to configure tabs with caching options. Cached tabs store their content after the initial render to improve performance, while non-cached tabs re-render their content every time they are selected.