Layout
Splitter
Two resizable panes with a focusable divider — the WAI-ARIA window splitter. Drag it, or focus it and use the arrow keys.
import { Splitter } from '@reactloom/ui';Examples
Sidebar and content
Enter collapses the first pane and restores it.
import { Splitter } from '@reactloom/ui';
export default function Example() {
return (
<div style={{ blockSize: 260, inlineSize: '100%', border: '1px solid var(--pl-color-border-default)', borderRadius: 8, overflow: 'hidden' }}>
<Splitter aria-label="Mailboxes" defaultSize={28} minSize={15} maxSize={60}>
<nav aria-label="Mailboxes" style={{ padding: 12 }}>
<strong>Mailboxes</strong>
<ul style={{ margin: '8px 0 0', paddingInlineStart: 18 }}>
<li>Inbox</li>
<li>Sent</li>
<li>Archive</li>
</ul>
</nav>
<section aria-label="Message" style={{ padding: 12 }}>
<strong>Quarterly review</strong>
<p style={{ margin: '8px 0 0' }}>Focus the divider and press ← or →, Home or End; Enter collapses the mailboxes.</p>
</section>
</Splitter>
</div>
);
}Nested and controlled
A vertical splitter inside a horizontal one; size is controlled.
import { Splitter } from '@reactloom/ui';
import { useState } from 'react';
export default function Example() {
const [editor, setEditor] = useState(65);
return (
<div style={{ blockSize: 300, inlineSize: '100%', border: '1px solid var(--pl-color-border-default)', borderRadius: 8, overflow: 'hidden' }}>
<Splitter aria-label="Files" defaultSize={25}>
<div style={{ padding: 12 }}>Files</div>
<Splitter aria-label="Editor" orientation="vertical" size={editor} onSizeChange={setEditor} minSize={30}>
<div style={{ padding: 12 }}>Editor ({Math.round(editor)}%)</div>
<div style={{ padding: 12, background: 'var(--pl-color-bg-subtle)', blockSize: '100%' }}>Terminal</div>
</Splitter>
</Splitter>
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
childrenrequiredThe two panes. | [ReactNode, ReactNode] | — |
aria-labelrequiredName of the separator — usually the first pane’s name. | string | — |
orientationHorizontal puts the panes side by side. | 'horizontal' | 'vertical' | 'horizontal' |
size / defaultSize / onSizeChangeFirst pane in percent. | number | 50 |
minSize · maxSizeLimits in percent. | number | 10 · 90 |
stepArrow-key step. | number | 5 |
collapsibleEnter collapses and restores. | boolean | true |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-dragging] | present when on |
[data-orientation] | horizontal · vertical |
Theme tokens it reads
--pl-color-accent-solid --pl-color-border-default --pl-color-border-strong --pl-focus-ring-color --pl-focus-ring-width --pl-radius-full --pl-radius-xs
Accessibility
- The divider is role="separator" with aria-valuenow, aria-controls (the first pane) and a name.
- Arrow keys follow the reading direction in right-to-left layouts.
- Pointer drags use pointer capture, so the pointer can leave the handle.
| Key | Action |
|---|---|
| ← → (or ↑ ↓) | Resize by a step |
| Home / End | Minimum / maximum |
| Enter | Collapse or restore the first pane |
Usage guidelines
Do
- Give each pane a landmark or heading so people know what they resize.
- Remember the size between visits.
Don’t
- Don’t put essential content in a pane that can collapse without a way back.