useResizable @astryx-svelte/core v0.3.0 · Resizable

Usage

Hook for adding drag-to-resize behavior to layout regions. Supports single-region and multi-region configurations with snap points, collapsible panels, localStorage persistence, and cascade resize ordering.
ts
import { Resizable } from '@astryx-svelte/core';

Best practices

GuidancePractices
DoUse with Layout or AppShell sidebar for resizable navigation panels.
DoSet autoSaveId to persist user-chosen sizes across page reloads.
Don'tSet minSizePx too small; content becomes unreadable. Prefer collapsible for panels that can hide entirely.

Parameters

ParameterTypeDefaultDescription
defaultSize number | stringInitial size in pixels or percentage string (e.g. "20%").
minSizePx number50Minimum size in pixels.
maxSizePx numberInfinityMaximum size in pixels.
collapsible booleanfalseWhether dragging below the collapsed threshold collapses the region to zero.
snaps number[]Pixel values to snap to during drag.
autoSaveId stringKey for localStorage persistence of size across sessions.

Returns

FieldTypeDefaultDescription
size numberCurrent size in pixels.
isCollapsed booleanWhether the region is currently collapsed.
collapse () => voidProgrammatically collapse the region.
expand () => voidExpand from collapsed state.
resize (size: number) => voidResize to a specific pixel value.
props ResizablePropsProps to spread on the resizable component or pass to ResizeHandle.

Examples

Common configurations, variations, and states.
Resizable — Collapsible with snap points
A collapsible sidebar with snap points, driven by useResizable. Dragging snaps to preset widths, dragging past the minimum collapses the panel, and the expand method restores it programmatically.