Skip to content

ColumnResizeHandle ​

An invisible strip on the free edge of a column or row that starts a drag from useColumnResize. The column needs position: relative and draws its own border.

tsx
import { ColumnResizeHandle, useColumnResize } from '@adecore/ui';
tsx
import { ColumnResizeHandle, useColumnResize } from '@adecore/ui';
import { useRef, useState } from 'react';

export default function ColumnResizeHandleDemo() {
    const column = useRef<HTMLElement>(null);
    const [width, setWidth] = useState(220);
    const { startResize } = useColumnResize(column, { size: width, min: 160, max: () => 400, from: 'left', onSize: setWidth });

    return (
        <div className="flex h-56 w-full overflow-hidden rounded-lg border border-border bg-bg">
            <aside ref={column} className="relative shrink-0 border-r border-border bg-surface p-3 text-xs text-text-muted" style={{ width }}>
                Drag my right edge: {width} pixels.
                <ColumnResizeHandle from="left" onPointerDown={startResize} />
            </aside>
            <div className="grow p-3 text-xs text-text-faint">The rest of the view.</div>
        </div>
    );
}

from is the edge the column hangs from, as passed to the hook. The handle is an 8 pixel strip on the opposite edge. It is pointer only, so offer keyboard users another way, such as a setting.

Props ​

PropTypeDefault
fromColumnEdgeRequired. 'left' | 'right' | 'top' | 'bottom'
onPointerDown(event: PointerEvent) => voidRequired. startResize from the hook.
classNamestring
styleCSSPropertiesInline dimensions or placement, such as a wider gap.
refRef<HTMLDivElement>

ColumnResizeHandleProps is an exported type.

Licenses and third-party notices are listed in each package.