Resizable
A panel with a drag handle on one edge that changes its width or height.
<arc-resizable>Overview
Resizable wraps one panel and puts a handle on one of its edges. Drag the handle to change the panel's width (direction="horizontal") or height (direction="vertical"). The handle sits on the end edge by default, which is the right edge in a left-to-right page or the bottom. Set handle="start" for a panel docked against the far side of its container.
Dragging uses Pointer Events with pointer capture, so mouse, touch and pen all work. The size is clamped between min-size and max-size, written to the --panel-size custom property as you drag, and reported in an arc-resize event on every change. Listen to that event to save the size.
The handle is a focusable role="separator" with aria-valuenow and aria-valuemin, plus aria-valuemax when max-size is set. Arrow keys resize in 5px steps, or 20px with Shift. The visible bar is 4px wide, with an invisible hit area 4px wider on each side, and it turns the accent color on hover and focus.
Guidelines
Do
- Set `min-size` so the panel can't shrink past usable, for example 150px for a sidebar
- Set `max-size` so the panel can't take over the viewport
- Save the size from `arc-resize` to localStorage or your backend so it survives a reload
- Use SplitPane when two regions share one divider
Don't
- Don't set `min-size` and `max-size` to the same value. The panel then can't resize
- Don't put the handle right next to a scrollbar, where people mistake one for the other
- If you restyle the handle part, keep its `::before` hit area, or the 4px bar gets hard to grab
Features
- `arc-resize` carries `{ size }` in pixels
- The handle's accessible name is "Resize handle"
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-resizable direction="horizontal" size="200">
<div>Resizable panel</div>
</arc-resizable>import { Resizable } from '@arclux/arc-ui-react';
export default function Example() {
return (
<Resizable direction="horizontal" size="200">
<div>Resizable panel</div>
</Resizable>
);
}<script setup>
import { Resizable } from '@arclux/arc-ui-vue';
</script>
<template>
<Resizable direction="horizontal" size="200">
<div>Resizable panel</div>
</Resizable>
</template><script>
import { Resizable } from '@arclux/arc-ui-svelte';
</script>
<Resizable direction="horizontal" size="200">
<div>Resizable panel</div>
</Resizable>import { Component } from '@angular/core';
import { Resizable } from '@arclux/arc-ui-angular';
@Component({
imports: [Resizable],
template: `
<arc-resizable direction="horizontal" size="200">
<div>Resizable panel</div>
</arc-resizable>
`,
})
export class MyComponent {}import { Resizable } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<Resizable direction="horizontal" size="200">
<div>Resizable panel</div>
</Resizable>
);
}import { Resizable } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<Resizable direction="horizontal" size="200">
<div>Resizable panel</div>
</Resizable>
);
}API
sizenumber300- Current size of the panel in pixels. Updated in real time during drag. Maps to the --panel-size CSS custom property.
direction'horizontal' | 'vertical''horizontal'- Which dimension the handle resizes. Horizontal resizes width, with the handle on an inline edge; vertical resizes height, with the handle on the top or bottom edge.
handle'end' | 'start''end'- Which edge the handle sits on.
end(the default) is the inline end (the right edge in a left-to-right page) or the bottom;startis the inline start or the top, for a panel docked against the far side of its container. Dragging the handle away from the panel grows it either way. minSizenumber100- Minimum allowed size in pixels. The panel cannot be dragged smaller than this value.
maxSizenumber0- Maximum allowed size in pixels. The panel cannot be dragged larger than this value. Defaults to no limit.
Events
arc-resizedetail:{ size: number }- Fired during and after panel resize with { size } detail