Split Pane
Resizable split layout with two panes.
<arc-split-pane>Overview
SplitPane divides its container into two panes with a handle between them. Use it when the reader should decide how two panes share the space. orientation="horizontal" puts the panes side by side, and vertical stacks them.
ratio sets the primary pane's share, from 0 to 1. Dragging the handle, or pressing the arrow keys, Home or End on it, changes the ratio, and min-ratio and max-ratio (0.15 and 0.85 by default) stop either pane from collapsing. arc-resize fires each time the ratio changes, with the new ratio in detail.ratio. A key press at a limit changes nothing and fires nothing.
The primary slot gets the ratio's share, and secondary fills the rest. Each pane scrolls on its own (overflow: auto).
Guidelines
Do
- Use it for editor and preview, list and detail, or tree and content layouts
- Keep `min-ratio` at 0.15 or more and `max-ratio` at 0.85 or less (the defaults) so both panes stay usable
- Save the ratio from `arc-resize` to keep the reader's layout. It fires on every drag step, so debounce the write
- Give the parent a set height, such as `100vh` or `flex: 1`. SplitPane takes 100% of it
- Use `orientation="vertical"` for top and bottom splits, such as a console under an editor
Don't
- Don't use it for a fixed two-column layout. Use PageLayout with `sidebar-left` or `sidebar-right`
- Don't set `min-ratio` and `max-ratio` so close together that the handle barely moves
- Don't put controls the reader needs in the secondary pane if `max-ratio` lets it get too narrow to show them
Features
- The handle is a 4px bar that turns `--border-bright` on hover and during a drag
- Text selection is off while the handle is being dragged
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-split-pane orientation="horizontal" ratio="0.4">
<div slot="primary">Primary pane</div>
<div slot="secondary">Secondary pane</div>
</arc-split-pane>import { SplitPane } from '@arclux/arc-ui-react';
export default function Example() {
return (
<SplitPane orientation="horizontal" ratio="0.4">
<div slot="primary">Primary pane</div>
<div slot="secondary">Secondary pane</div>
</SplitPane>
);
}<script setup>
import { SplitPane } from '@arclux/arc-ui-vue';
</script>
<template>
<SplitPane orientation="horizontal" ratio="0.4">
<div slot="primary">Primary pane</div>
<div slot="secondary">Secondary pane</div>
</SplitPane>
</template><script>
import { SplitPane } from '@arclux/arc-ui-svelte';
</script>
<SplitPane orientation="horizontal" ratio="0.4">
<div slot="primary">Primary pane</div>
<div slot="secondary">Secondary pane</div>
</SplitPane>import { Component } from '@angular/core';
import { SplitPane } from '@arclux/arc-ui-angular';
@Component({
imports: [SplitPane],
template: `
<arc-split-pane orientation="horizontal" ratio="0.4">
<div slot="primary">Primary pane</div>
<div slot="secondary">Secondary pane</div>
</arc-split-pane>
`,
})
export class MyComponent {}import { SplitPane } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<SplitPane orientation="horizontal" ratio="0.4">
<div slot="primary">Primary pane</div>
<div slot="secondary">Secondary pane</div>
</SplitPane>
);
}import { SplitPane } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<SplitPane orientation="horizontal" ratio="0.4">
<div slot="primary">Primary pane</div>
<div slot="secondary">Secondary pane</div>
</SplitPane>
);
}API
STEPnumber0.05- Keyboard step, and the larger Shift step: the same 5-and-20 as arc-resizable.
STEP_LARGEnumber0.2labelstring''- Accessible name for the divider, applied as
aria-label. Defaults to "Resize panes". orientation'horizontal' | 'vertical''horizontal'- Controls the split direction. Horizontal places panes side by side with a vertical divider. Vertical stacks panes top and bottom with a horizontal divider.
rationumber0.5- The proportion of space allocated to the primary pane, clamped to
minRatio..maxRatioon every path, including assignment from script. From 0 to 1. A value of 0.4 gives the primary pane 40% of the available width (or height in vertical mode). minRationumber0.15- Minimum allowed ratio. The divider cannot be dragged below this value, preventing the primary pane from collapsing.
maxRationumber0.85- Maximum allowed ratio. The divider cannot be dragged above this value, preventing the secondary pane from collapsing.
Events
arc-resizedetail:{ value: number, ratio: number }- Fired on every step of a divider drag and on every keyboard step, with the new ratio on both
detail.valueanddetail.ratio.