Skip to Content
NarakUI

Resize Handle

A drag handle on a panel edge. Pass size, minSize, maxSize, and onSizeChange together to make it a focusable separator that resizes by keyboard.

Keyboard resizing

Tab to the handle, then use the arrow keys to resize (Shift for larger steps) and Home or End to jump to minSize or maxSize. You can also drag the edge with a pointer or double-click to reset.

Canvas

Installation

pnpm dlx shadcn@latest add @narakui/resize-handle

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/resize-handle.json.

Usage

import { useState } from 'react';
import { ResizeHandle } from '@/components/ui/resize-handle';

function PanelLayout() {
  const [width, setWidth] = useState(240);

  return (
    <aside className="relative" style={{ width }}>
      <ResizeHandle
        aria-label="Resize details panel"
        position="left"
        size={width}
        minSize={160}
        maxSize={360}
        onSizeChange={setWidth}
      />
    </aside>
  );
}

Properties

PropTypeDefaultDescription
position'left' | 'right' | 'top''left'Edge of the parent panel where the handle sits
sizenumber—Current panel size in pixels. Pass with minSize, maxSize, and onSizeChange to enable keyboard resizing
minSizenumber—Minimum allowed panel size in pixels
maxSizenumber—Maximum allowed panel size in pixels
onSizeChange(size: number) => void—Called with the clamped next size on keyboard resize
isDraggingbooleanfalseKeeps the indicator visible and highlighted while dragging
barClassNamestring—Additional classes for the indicator line
aria-labelstring'Drag to resize'Accessible label for the resize separator
classNamestring—Additional classes for the hit target container