Skip to main content

Resizable

A Resizable component that allows users to resize an element's width by dragging a handle on either the left or right side. The width is persisted to local storage via the name prop.

Key Characteristics

  • Drag to resize: Resize by dragging a handle on the left or right side.
  • Persisted width: The resized width is saved to local storage using the name prop, so it survives page reloads.
  • Configurable bounds: Set minWidth, maxWidth, and initialWidth to constrain the resize range.
  • Polymorphic: Render as div, aside, nav, section, or other semantic HTML tags via the as prop.
  • Callback: Use the onResize callback to react to width changes in real time.

Import

import { Resizable } from '@andrejground/lab';

Usage

Drag the right edge to resize
Min: 200px
Max: 400px

Left Side

Set resizableSide="left" to place the drag handle on the left edge.

Drag the left edge to resize
Min: 200px
Max: 400px

onResize Callback

Use the onResize callback to track the current width in real time.

Resizable side: right
Current: px
Resizable side: left
Current: px