Resizable
Accessible resizable panel groups and layouts with collapsible stops, RTL, and keyboard support.
Accessible percentage-sized resizable panel groups with keyboard controls, collapsible stops, and nested orientations. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<proto-ui-shadcn-resizable-root
id="shadcn-resizable-hero"
class="h-56 w-full max-w-md rounded-lg border border-border bg-background overflow-hidden"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">One</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-root
id="shadcn-resizable-nested"
class="h-full w-full min-h-0"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Two</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Three</span>
</div>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-resizable-hero');
const nestedRoot = document.querySelector(
'#shadcn-resizable-nested'
);
setElementProps(root, {
defaultSizes: [50, 50],
constraints: [
{ min: 20, max: 75, collapsible: true },
{ min: 25 },
],
styleProfile: 'rhea',
});
setElementProps(nestedRoot, {
orientation: 'vertical',
defaultSizes: [25, 75],
constraints: [{ min: 20 }, { min: 25 }],
styleProfile: 'rhea',
});
root
.querySelectorAll(':scope > proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
setElementProps(
root.querySelector(':scope > proto-ui-shadcn-resizable-handle'),
{ index: 0, withHandle: true, styleProfile: 'rhea' }
);
nestedRoot
.querySelectorAll(':scope > proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
setElementProps(
nestedRoot.querySelector(
':scope > proto-ui-shadcn-resizable-handle'
),
{ index: 0, withHandle: true, styleProfile: 'rhea' }
);
</script>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import the prototypes directly from @proto.ui/prototypes-shadcn/resizable and adapt them for your target runtime:
import { resizableRoot, resizablePanel, resizableHandle,} from '@proto.ui/prototypes-shadcn/resizable';import { ShadcnResizableRoot, ShadcnResizablePanel, ShadcnResizableHandle,} from '../proto-ui/components/react';
export function Example() { return ( <ShadcnResizableRoot orientation="horizontal" defaultSizes={[50, 50]} className="h-56 max-w-md rounded-lg border border-border overflow-hidden" > <ShadcnResizablePanel index={0}>One</ShadcnResizablePanel> <ShadcnResizableHandle index={0} withHandle /> <ShadcnResizablePanel index={1}>Two</ShadcnResizablePanel> </ShadcnResizableRoot> );}Composition
Section titled “Composition”Proto UI’s resizableRoot, resizablePanel, and resizableHandle correspond to upstream shadcn/ui’s ResizablePanelGroup, ResizablePanel, and ResizableHandle:
ResizableRoot├── ResizablePanel (index: 0)├── ResizableHandle (index: 0)└── ResizablePanel (index: 1)- Place
NPanelelements (index: 0..N-1) andN - 1Handleelements (index: 0..N-2). EachHandleresizes only its adjacent pair while preserving their combined size and every other panel. - Each
Panelexposes its dimensionless percentage through--pui-sizefor staticflex-basislayout rules. Drag deltas normalize against panel extents, excluding fixed handle widths. - Pass
constraintsfor per-panelmin(0),max(100),collapsible(false), andcollapsedSize(0). Passsizesfor controlled mode and handlesizesChange/sizesCommit. - Supports arrow keys,
Shift10× acceleration,Home/End, andEntercollapse toggles. EachHandledefaults its accessible name toResize panels.
Examples
Section titled “Examples”Vertical
Section titled “Vertical”Use orientation="vertical" for vertical resizing.
<proto-ui-shadcn-resizable-root
id="shadcn-resizable-vertical"
class="h-56 w-full max-w-md rounded-lg border border-border bg-background overflow-hidden"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Header</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Content</span>
</div>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-resizable-vertical');
setElementProps(root, {
orientation: 'vertical',
defaultSizes: [25, 75],
constraints: [{ min: 20 }, { min: 25 }],
styleProfile: 'rhea',
});
root
.querySelectorAll('proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
setElementProps(
root.querySelector('proto-ui-shadcn-resizable-handle'),
{ index: 0, styleProfile: 'rhea' }
);
</script>Handle
Section titled “Handle”Use the withHandle prop on Handle to display a visible grip handle, or omit it for a minimal 1px separator.
<div class="flex w-full max-w-md flex-col gap-4">
<proto-ui-shadcn-resizable-root
id="shadcn-resizable-with-handle"
class="h-40 w-full max-w-md rounded-lg border border-border bg-background overflow-hidden"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Sidebar</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Content</span>
</div>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
<proto-ui-shadcn-resizable-root
id="shadcn-resizable-hairline"
class="h-32 w-full max-w-md rounded-lg border border-border bg-background overflow-hidden"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Left</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Right</span>
</div>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const withGrip = document.querySelector(
'#shadcn-resizable-with-handle'
);
setElementProps(withGrip, {
defaultSizes: [25, 75],
constraints: [{ min: 15 }, { min: 30 }],
styleProfile: 'rhea',
});
withGrip
.querySelectorAll('proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
withGrip
.querySelectorAll('proto-ui-shadcn-resizable-handle')
.forEach((handle, index) =>
setElementProps(handle, {
index,
withHandle: true,
styleProfile: 'rhea',
})
);
const hairline = document.querySelector(
'#shadcn-resizable-hairline'
);
setElementProps(hairline, {
defaultSizes: [50, 50],
constraints: [{ min: 20 }, { min: 20 }],
styleProfile: 'rhea',
});
hairline
.querySelectorAll('proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
setElementProps(
hairline.querySelector('proto-ui-shadcn-resizable-handle'),
{ index: 0, withHandle: false, styleProfile: 'rhea' }
);
</script>Pass direction="rtl" on Root to mirror panel order and horizontal arrow-key increments.
<proto-ui-shadcn-resizable-root
id="shadcn-resizable-rtl"
class="h-56 w-full max-w-md rounded-lg border border-border bg-background overflow-hidden"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">واحد</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-root
id="shadcn-resizable-rtl-nested"
class="h-full w-full min-h-0"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">اثنان</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">ثلاثة</span>
</div>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#shadcn-resizable-rtl');
const nestedRoot = document.querySelector(
'#shadcn-resizable-rtl-nested'
);
setElementProps(root, {
direction: 'rtl',
defaultSizes: [50, 50],
constraints: [{ min: 20 }, { min: 20 }],
styleProfile: 'rhea',
});
setElementProps(nestedRoot, {
orientation: 'vertical',
direction: 'rtl',
defaultSizes: [25, 75],
constraints: [{ min: 20 }, { min: 25 }],
styleProfile: 'rhea',
});
root
.querySelectorAll(':scope > proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
setElementProps(
root.querySelector(':scope > proto-ui-shadcn-resizable-handle'),
{ index: 0, withHandle: true, styleProfile: 'rhea' }
);
nestedRoot
.querySelectorAll(':scope > proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
setElementProps(
nestedRoot.querySelector(
':scope > proto-ui-shadcn-resizable-handle'
),
{ index: 0, withHandle: true, styleProfile: 'rhea' }
);
</script>Multi-panel & Collapsible
Section titled “Multi-panel & Collapsible”Combine defaultSizes and constraints for a three-panel workspace. Focus the first handle and press Enter to toggle the collapsible sidebar.
<proto-ui-shadcn-resizable-root
id="shadcn-resizable-collapsible"
class="h-56 w-full max-w-2xl rounded-lg border border-border bg-background overflow-hidden"
>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Sidebar</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Editor</span>
</div>
</proto-ui-shadcn-resizable-panel>
<proto-ui-shadcn-resizable-handle></proto-ui-shadcn-resizable-handle>
<proto-ui-shadcn-resizable-panel>
<div class="flex h-full items-center justify-center p-6">
<span class="font-semibold text-sm">Inspector</span>
</div>
</proto-ui-shadcn-resizable-panel>
</proto-ui-shadcn-resizable-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector(
'#shadcn-resizable-collapsible'
);
setElementProps(root, {
defaultSizes: [25, 50, 25],
constraints: [
{ min: 15, max: 35, collapsible: true },
{ min: 30 },
{ min: 15, max: 35 },
],
styleProfile: 'rhea',
});
root
.querySelectorAll('proto-ui-shadcn-resizable-panel')
.forEach((panel, index) =>
setElementProps(panel, { index, styleProfile: 'rhea' })
);
root
.querySelectorAll('proto-ui-shadcn-resizable-handle')
.forEach((handle, index) =>
setElementProps(handle, {
index,
withHandle: true,
styleProfile: 'rhea',
})
);
</script>| Prop | Type | Default |
|---|---|---|
sizes | readonly number[] | — |
defaultSizes | readonly number[] | — |
constraints | readonly ResizablePanelConstraint[] | [] |
value | number | — |
defaultValue | number | 50 |
min | number | 10 |
max | number | 90 |
step | number | 1 |
collapsible | boolean | false |
disabled | boolean | false |
readOnly | boolean | false |
orientation | 'horizontal' 'vertical' | 'horizontal' |
direction | 'ltr' 'rtl' | 'ltr' |
styleProfile | ShadcnStyleId | 'new-york-v4' |
Panel & Handle
Section titled “Panel & Handle”| Prop | Type | Default |
|---|---|---|
Panel.index | number | 0 |
Panel.styleProfile | ShadcnStyleId | 'new-york-v4' |
Handle.index | number | 0 |
Handle.withHandle | boolean | false |
Handle.styleProfile | ShadcnStyleId | 'new-york-v4' |
- Exposed states: Root exposes
valueandsizes; Panel exposessize; Handle exposesvalue,focusVisible, anddisabled. - Events: Root emits
sizesChange/sizesCommit({ sizes }) and legacy two-panelvalueChange/valueCommit({ value }). Cancelled drags emit no*Commit. - Methods: Root exposes
requestResize(index, next, commit?),requestSizes(next, commit?),requestValue(next, commit?), andcancelResize().