SplitPanel
A split-panel layout that divides available space into resizable primary and secondary areas.
import { SplitPanel } from "@schukai/monster/source/components/layout/split-panel.mjs";The split can be dragged, reset, or driven through public methods.
Introduction
The Monster SplitPanel divides available space into two coordinated areas. Use it when users need a primary work surface next to a secondary detail, preview or navigation pane.
When to use SplitPanel
- Use it for master-detail layouts: Lists next to previews or editors next to inspectors are typical cases.
- Use it when both sides matter at the same time: The layout keeps two related views visible together.
- Do not use it on content that must collapse into one undifferentiated column: Simpler layouts are often clearer on small screens.
Typical mistakes
Give the two areas distinct roles. A split layout is most useful when users immediately understand what belongs to the primary side and what belongs to the supporting side.
Split Panel Simple
The main pane can grow while the navigation pane stays quickly accessible through reset and focus presets.
Double click the dragger to cycle through min, initial, and max dimensions.
The main pane can grow while the navigation pane stays quickly accessible through reset and focus presets.
Double click the dragger to cycle through min, initial, and max dimensions.
Javascript
import "@schukai/monster/source/components/layout/panel.mjs";
import "@schukai/monster/source/components/layout/split-panel.mjs";
const splitPanel = document.getElementById("split-simple-demo");
const log = document.getElementById("split-simple-log");
document
.getElementById("split-simple-focus-start")
?.addEventListener("click", () => {
splitPanel?.fullStartScreen();
});
document
.getElementById("split-simple-reset")
?.addEventListener("click", () => {
splitPanel?.resetScreen();
});
document
.getElementById("split-simple-focus-end")
?.addEventListener("click", () => {
splitPanel?.fullEndScreen();
});
splitPanel?.addEventListener("monster-dimension-changed", (event) => {
log.textContent = `Dimension: ${event.detail.dimension}`;
});
import "@schukai/monster/source/components/layout/popper.mjs";HTML
<section style="display:grid;gap:var(--monster-space-4);container-type:inline-size;">
<div
style="display:flex;gap:var(--monster-space-3);flex-wrap:wrap;align-items:center;padding:var(--monster-space-4);background:var(--monster-bg-color-primary-2);color:var(--monster-color-primary-2);border:1px solid var(--monster-color-border-primary-2);"
>
<button id="split-simple-focus-start" type="button">Focus navigation</button>
<button id="split-simple-reset" type="button">Reset</button>
<button id="split-simple-focus-end" type="button">Focus content</button>
<span id="split-simple-log">Dimension: 38%</span>
</div>
<div style="block-size:24rem;min-block-size:24rem;border:1px solid var(--monster-color-border-secondary-2);">
<monster-split-panel
id="split-simple-demo"
data-monster-option-dimension-initial="38%"
data-monster-option-dimension-min="22%"
data-monster-option-dimension-max="72%"
>
<monster-panel slot="start">
<div style="display:grid;gap:var(--monster-space-3);padding:var(--monster-space-4);background:var(--monster-bg-color-secondary-2);color:var(--monster-color-secondary-2);min-block-size:100%;">
<strong>Navigation</strong>
<button type="button">Inbox</button>
<button type="button">Orders</button>
<button type="button">Inventory</button>
<button type="button">Exports</button>
</div>
</monster-panel>
<monster-panel slot="end">
<div style="display:grid;gap:var(--monster-space-4);padding:var(--monster-space-4);background:var(--monster-bg-color-primary-1);color:var(--monster-color-primary-1);min-block-size:100%;">
<strong>Workspace</strong>
<p style="margin:0;">
The main pane can grow while the navigation pane stays quickly
accessible through reset and focus presets.
</p>
<p style="margin:0;">Double click the dragger to cycle through min, initial, and max dimensions.</p>
</div>
</monster-panel>
</monster-split-panel>
</div>
</section>Stylesheet
/** no additional stylesheet is defined **/Split Panel Presets
This second example switches the split to horizontal mode. It is a good fit for editor and preview layouts where the reading flow stays top to bottom.
Keep the form fields above and the live preview below.
Horizontal mode is useful when the page is wider than it is tall.
Keep the form fields above and the live preview below.
Horizontal mode is useful when the page is wider than it is tall.
Javascript
import "@schukai/monster/source/components/layout/panel.mjs";
import "@schukai/monster/source/components/layout/split-panel.mjs";HTML
<div style="block-size:24rem;min-block-size:24rem;border:1px solid var(--monster-color-border-primary-2);">
<monster-split-panel
data-monster-option-splitType="horizontal"
data-monster-option-dimension-initial="58%"
data-monster-option-dimension-min="35%"
data-monster-option-dimension-max="78%"
>
<monster-panel slot="start">
<div style="display:grid;gap:var(--monster-space-3);padding:var(--monster-space-4);background:var(--monster-bg-color-primary-2);color:var(--monster-color-primary-2);min-block-size:100%;">
<strong>Editor</strong>
<p style="margin:0;">Keep the form fields above and the live preview below.</p>
</div>
</monster-panel>
<monster-panel slot="end">
<div style="display:grid;gap:var(--monster-space-3);padding:var(--monster-space-4);background:var(--monster-bg-color-secondary-2);color:var(--monster-color-secondary-2);min-block-size:100%;">
<strong>Preview</strong>
<p style="margin:0;">Horizontal mode is useful when the page is wider than it is tall.</p>
</div>
</monster-panel>
</monster-split-panel>
</div>Stylesheet
/** no additional stylesheet is defined **/Component Design
The Monster Split Panel component uses the Shadow DOM to encapsulate its internal structure and styles. This ensures that the component's layout and behavior remain unaffected by external styles or scripts. It divides the available space into two resizable panels, offering either a vertical or horizontal split layout.
Shadow DOM and Accessibility
The Shadow DOM ensures that the internal structure of the Split Panel is isolated from external interference. Accessibility is maintained by providing proper ARIA roles, focus management, and keyboard interaction support, enabling all users, including those using assistive technologies, to interact with the component seamlessly.
Customizing Through Exported Parts
The Monster Split Panel exposes specific exported parts for targeted styling using the CSS part selector. This allows developers to customize the appearance of the panels and the draggable handle while preserving the component's functionality and encapsulation.
Available Part Attributes
control: Represents the entire split panel container.startPanel: Targets the first (start) panel in the split layout.endPanel: Refers to the second (end) panel.dragger: Styles the draggable handle between the two panels.handle: Refers to the internal part of the draggable element.
Below is an example of how to customize the appearance of the draggable handle and panels using the CSS part attributes.
monster-split-panel::part(control) {
border: 1px solid #ccc;
border-radius: 6px;
background-color: #f9f9f9;
}
monster-split-panel::part(startPanel),
monster-split-panel::part(endPanel) {
background-color: #ffffff;
padding: 16px;
}
monster-split-panel::part(dragger) {
background-color: #007bff;
width: 5px;
cursor: ew-resize;
}
monster-split-panel::part(handle) {
background-color: #0056b3;
width: 100%;
height: 100%;
}
Explanation of the Example
monster-split-panel::part(control): Styles the entire split panel container with a light border and rounded corners.monster-split-panel::part(startPanel)andendPanel: Adds padding and background color to both panels.monster-split-panel::part(dragger): Styles the draggable separator with a blue background and sets a cursor for resizing.monster-split-panel::part(handle): Targets the draggable handle's internal area to ensure consistent styling.
Accessibility
The Monster Split Panel component includes accessibility features to support a wide range of users:
- Keyboard Interaction: Users can trigger predefined actions (e.g., reset dimensions) using keyboard events.
- ARIA Roles: The component employs proper ARIA roles and attributes for better screen reader support.
- Focus Management: Focus is managed appropriately when interacting with the draggable handle.
These features ensure that the Split Panel component delivers an inclusive experience for all users, including those utilizing assistive technologies.
HTML Structure
<monster-split-panel></monster-split-panel>JavaScript Initialization
const element = document.createElement('monster-split-panel');
document.body.appendChild(element);Exported
SplitPanel, TYPE_VERTICAL, TYPE_HORIZONTALDerived from
CustomElementOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CustomElement.
- since
- deprecated
Properties and Attributes
The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CustomElement.
data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.data-monster-option-[name]: Sets the value of the configuration option[name]for the collapse component when used as an HTML attribute.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CustomElement.
Behavioral methods
resetScreen()data-monster-options must be used. The individual configuration values can be found in the table.State query methods
isFullEndScreen()data-monster-options must be used. The individual configuration values can be found in the table.isFullStartScreen()data-monster-options must be used. The individual configuration values can be found in the table.isInitialScreen()data-monster-options must be used. The individual configuration values can be found in the table.Structural methods
setContent(html)html
data-monster-options must be used. The individual configuration values can be found in the table.setDimension(dimension)dimension{string}: - The dimension to be set, can be in percentage or absolute value.
- {object}: Returns the current object instance for chaining.
Static methods
[instanceSymbol]()- {symbol}
instanceof operator.getCSSStyleSheet()- {CSSStyleSheet[]}
getTag()- {string}
Lifecycle methods
Lifecycle methods are called by the environment and are usually not intended to be called directly.
[assembleMethodSymbol]()- {Monster.Components.Host.Viewer}
Other methods
fullEndScreen()data-monster-options must be used. The individual configuration values can be found in the table.fullStartScreen()data-monster-options must be used. The individual configuration values can be found in the table.Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.