Components
Resizable Panel
Resizable panel groups with drag handles and keyboard support.
Installation
$ npx veil-ui@latest add resizable-panelUsage
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable-panel";
<ResizablePanelGroup orientation="horizontal" className="h-64 rounded-md border">
<ResizablePanel defaultSize="30%">Sidebar</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize="70%">Content</ResizablePanel>
</ResizablePanelGroup>;Examples
Horizontal
Sidebar
Content
Vertical
Top
Bottom
With handle
Panel A
Panel B
Sizes without a unit are percentages; pass "200px" or {200} for pixel
constraints.
API reference
ResizablePanelGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | Axis along which panels resize. |
| defaultLayout | Layout | — | Remembered layout for the group. |
| ...props | React.ComponentProps<typeof Group> | — | All react-resizable-panels group props. |
ResizablePanel
Accepts defaultSize, minSize, maxSize, collapsible, collapsedSize and
the rest of the panel props from react-resizable-panels.
ResizableHandle
| Prop | Type | Default | Description |
|---|---|---|---|
| withHandle | boolean | false | Show a grip affordance in the middle of the handle. |
| ...props | React.ComponentProps<typeof Separator> | — | All react-resizable-panels separator props. |
Accessibility
- The underlying library provides keyboard resizing and ARIA separator semantics.
- The optional grip is decorative; the handle itself remains the interactive control.
- Give the group a fixed height, otherwise there is no space to resize.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add resizable-panel --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { GripVertical } from "lucide-vue-next";
import { computed, ref } from "vue";
import { cn } from "@/lib/utils";
import { useResizable } from "./use-resizable";
const props = withDefaults(
defineProps<{
withHandle?: boolean;
class?: string;
}>(),
{ withHandle: false },
);
const { orientation, sizes, container, registerHandle } = useResizable();
const index = registerHandle();
const dragging = ref(false);
const style = computed(() =>
orientation.value === "vertical"
? { cursor: "row-resize" }
: { cursor: "col-resize" },
);
function onPointerDown(event: PointerEvent) {
event.preventDefault();
dragging.value = true;
const element = container.value;
const startX = event.clientX;
const startY = event.clientY;
const size =
orientation.value === "horizontal"
? (element?.clientWidth ?? 1)
: (element?.clientHeight ?? 1);
const first = sizes.value[index] ?? 50;
const second = sizes.value[index + 1] ?? 50;
const total = first + second;
const minimum = Math.min(10, total / 2);
function onMove(move: PointerEvent) {
const delta =
orientation.value === "horizontal"
? move.clientX - startX
: move.clientY - startY;
const next = Math.min(
Math.max(first + (delta / Math.max(size, 1)) * 100, minimum),
total - minimum,
);
sizes.value[index] = next;
sizes.value[index + 1] = total - next;
}
function onUp() {
dragging.value = false;
window.removeEventListener("pointermove", onMove);
window.removeEventListener("pointerup", onUp);
}
window.addEventListener("pointermove", onMove);
window.addEventListener("pointerup", onUp);
}
</script>
<template>
<div
data-slot="resizable-handle"
role="separator"
:aria-orientation="orientation"
:tabindex="0"
:style="style"
:class="
cn(
'group relative flex items-center justify-center bg-border outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50',
orientation === 'horizontal' ? 'w-px' : 'h-px w-full',
props.class,
)
"
@pointerdown="onPointerDown"
>
<div
v-if="withHandle"
class="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border"
>
<GripVertical class="size-2.5" aria-hidden="true" />
</div>
</div>
</template>