Skip to content

Splitter

The Splitter component divides a container into resizable panels, allowing users to adjust the size of each panel by dragging the divider (gutter) between them.

This component has no external dependencies beyond the core Metro UI library.

<div data-role="splitter">
<div>Panel 1 Content</div>
<div>Panel 2 Content</div>
<div>Panel 3 Content</div>
</div>
ParameterTypeDefaultDescription
splitterDeferrednumber0Deferred initialization time in milliseconds
splitstring”vertical”Split mode: “vertical” or “horizontal”
splitSizesstring/arraynullInitial sizes of the split panels (comma-separated string or array)
gutterSizenumber5Size of the gutter between panels in pixels
gutterStylestring”default”Style of the gutter: “default”, “ribbed”, “dashed”, “dotted”
minSizesstring/arraynullMinimum sizes of the panels (comma-separated string or array)
childrenstring”*“Selector for the child elements to be split
gutterClickstring”expand”Behavior when the gutter is clicked
saveStatebooleanfalseWhether to save the state of the splitter in browser storage
noResizebooleanfalseWhether to disable resizing
EventDescription
onResizeStartTriggered when resizing starts
onResizeStopTriggered when resizing stops
onResizeSplitTriggered during resizing
onResizeWindowTriggered when the window is resized
onSplitterCreateTriggered when the splitter is created

Sets the sizes of the split panels.

// Set panel sizes to 30%, 40%, 30%
Metro.getPlugin('#mySplitter', 'splitter').size([30, 40, 30]);

Updates the splitter when specified attributes change.

Metro.getPlugin('#mySplitter', 'splitter').changeAttribute('data-split-sizes');

Removes the splitter component and its event handlers.

Metro.getPlugin('#mySplitter', 'splitter').destroy();

The Splitter component can be styled using the following CSS variables:

VariableDefault (Light)Dark ModeDescription
—splitter-color#F8F8F8#1e1f22Background color of the splitter
—splitter-color-active#F8F8F8#26282eBackground color of the active splitter
—splitter-gutter-color#BEBEBE#4a4d51Color of the gutter
—splitter-gutter-color-active#BEBEBE#2e436eColor of the active gutter
—gutter-dot-size2px2pxSize of the dots in the dotted gutter style
—gutter-bg-size8px8pxSize of the background in the dotted gutter style
—gutter-bg-positioncalc(var(—gutter-bg-size) / 2)calc(var(—gutter-bg-size) / 2)Position of the background in the dotted gutter style
—gutter-dot-colorvar(—splitter-color)var(—splitter-color)Color of the dots in the dotted gutter style
—gutter-dot-color-secondvar(—splitter-gutter-color)var(—splitter-gutter-color)Secondary color of the dots in the dotted gutter style
  • .splitter - Main class for the splitter component
  • .split-block - Class for the split panels
  • .gutter - Class for the gutter element
  • .vertical - Class for vertical orientation (panels side by side)
  • .horizontal - Class for horizontal orientation (panels stacked)
  • .active - Class for active state (applied during resizing)
  • .static-size - Class for non-resizable splitter
  • .gutter-style-ribbed - Class for ribbed gutter style
  • .gutter-style-dashed - Class for dashed gutter style
  • .gutter-style-dotted - Class for dotted gutter style

You can customize the appearance of the Splitter by overriding the CSS variables:

:root {
--splitter-color: #f0f0f0;
--splitter-color-active: #e0e0e0;
--splitter-gutter-color: #c0c0c0;
--splitter-gutter-color-active: #a0a0a0;
}

The Splitter component supports different gutter styles:

  • Default: No additional class
  • Ribbed: Add gutter-style-ribbed class
  • Dashed: Add gutter-style-dashed class
  • Dotted: Add gutter-style-dotted class
<div data-role="splitter" class="gutter-style-ribbed">
<div>Panel 1 Content</div>
<div>Panel 2 Content</div>
</div>

The Splitter component supports two split modes:

  • Vertical: Panels are arranged horizontally, with vertical gutters
  • Horizontal: Panels are arranged vertically, with horizontal gutters
<div data-role="splitter" data-split="vertical">
<div>Panel 1 Content</div>
<div>Panel 2 Content</div>
</div>
<div data-role="splitter" data-split="horizontal">
<div>Panel 1 Content</div>
<div>Panel 2 Content</div>
</div>

You can disable resizing by setting the data-no-resize attribute to true:

<div data-role="splitter" data-no-resize="true">
<div>Panel 1 Content</div>
<div>Panel 2 Content</div>
</div>
<div data-role="splitter">
<div>Left Panel</div>
<div>Right Panel</div>
</div>
<div data-role="splitter" data-split="horizontal" data-split-sizes="30, 70">
<div>Top Panel (30%)</div>
<div>Bottom Panel (70%)</div>
</div>
<div data-role="splitter" data-min-sizes="100, 200, 100">
<div>Left Panel (min 100px)</div>
<div>Middle Panel (min 200px)</div>
<div>Right Panel (min 100px)</div>
</div>
<div id="mySplitter" data-role="splitter" data-save-state="true">
<div>Panel 1 Content</div>
<div>Panel 2 Content</div>
</div>
<div data-role="splitter">
<div>Left Panel</div>
<div data-role="splitter" data-split="horizontal">
<div>Top Right Panel</div>
<div>Bottom Right Panel</div>
</div>
</div>