SplitView
Description
The SplitView component creates a two-pane container that arranges two child components separated by a draggable splitter. This component is ideal for displaying resizable panels side-by-side (or top/bottom when using horizontal variations) within your UI. It is part of the Tesserae Components group, which provides various UI controls for building interactive interfaces.
Usage
Instantiate a SplitView using the helper method from Tesserae.UI. You can add content to the left and right panels using the Left() and Right() methods. By default, the splitter is non-resizable; calling Resizable() enables drag-to-resize functionality.
Below is a basic usage example:
Methods
Resizable(Action
onResizeEnd = null)
Enables drag-resizing for the split view panels. Optionally, you can provide a callback that receives the final width of the resized panel in pixels.
• Parameters:
- onResizeEnd: An Actioncallback invoked when resizing ends. NotResizable()
Disables the resizable behavior by removing the drag event bindings and resetting the splitter's style.Left(IComponent component, string background = "")
Sets the left pane content of the split view. An optional background string can be specified.
• Parameters:
- component: The IComponent to display in the left panel.
- background: (Optional) A CSS background value.Right(IComponent component, string background = "")
Sets the right pane content of the split view. An optional background string can be specified.
• Parameters:
- component: The IComponent to display in the right panel.
- background: (Optional) A CSS background value.PanelStyle()
Applies a panel style to the split view by adding a specific CSS class.SplitInMiddle()
Adjusts the split view such that both panels share the available space equally, by removing any side-specific styling.Close()
Closes the currently collapsed (smaller) panel. It throws an exception if the split view is not configured as a left or right split.Open()
Opens the currently collapsed panel. It throws an exception if the split view is not configured as a left or right split.LeftIsSmaller(UnitSize leftSize, UnitSize maxLeftSize = null, UnitSize minLeftSize = null)
Configures the split view such that the left panel has a fixed or smaller size relative to the right panel.
• Parameters:
- leftSize: The desired width for the left panel.
- maxLeftSize: (Optional) The maximum width allowed for the left panel.
- minLeftSize: (Optional) The minimum width allowed for the left panel.RightIsSmaller(UnitSize rightSize, UnitSize maxRightSize = null, UnitSize minRightSize = null)
Configures the split view such that the right panel has a fixed or smaller size relative to the left panel.
• Parameters:
- rightSize: The desired width for the right panel.
- maxRightSize: (Optional) The maximum width allowed for the right panel.
- minRightSize: (Optional) The minimum width allowed for the right panel.Render()
Renders and returns the underlying HTMLElement representing the split view.
Public Properties
There are no explicitly exposed public properties for the SplitView component. Configuration and state management are handled via its fluent interface methods.
Samples
Basic SplitView with Resizable Panels
This sample demonstrates how to create a SplitView, assign components to the left and right panels, and enable panel resizing on the fly.
Configuring Side-Specific Panel Sizes
This sample shows how to configure the SplitView so that one of the panels is set to a fixed smaller width.