re-resizable
A dependency-free React component that adds drag-to-resize handles, grid snapping, and aspect-ratio locking to any element.
Repository Health
Technical Analysis
re-resizable is a React component library that wraps any child content in a resizable box, exposing eight drag handles (four edges, four corners) for freeform or constrained resizing. It ships as a single dependency-free package — no runtime dependencies beyond React itself — and supports both controlled (size) and uncontrolled (defaultSize) usage, matching how the rest of a typical React app already manages state.
Beyond basic drag-resize, it handles the edge cases teams tend to hand-roll themselves: aspect-ratio locking (with extra width/height for adjacent sidebars or headers), grid and snap-point resizing, resize boundaries scoped to the window, the parent, or an arbitrary element, and correct behavior inside CSS-scaled ancestors via a scale prop. An imperative updateSize instance method lets consumers resize programmatically outside the normal props flow.
What You Get
- Eight-direction resize handles (edges + corners) with per-direction enable/disable control
- Controlled and uncontrolled size APIs (
sizevsdefaultSize) with resize start/move/stop callbacks - Grid, snap-point, and aspect-ratio-lock resize constraints, including bounds scoped to window, parent, or element
- Zero runtime dependencies and a small footprint, shipped as both ES5 and ESM builds
- Full TypeScript types and an imperative
updateSizeAPI for programmatic resizing
Common Use Cases
- Resizable side panels and dashboard widgets
- User-resizable image/video/media containers that preserve aspect ratio
- Split-pane / IDE-style layouts with draggable dividers
- Resizable text areas, chat boxes, or embeds with min/max size constraints
Under The Hood
Architecture
The library centers on a single Resizable class component (src/index.tsx, extending PureComponent) that owns all resize state — original pointer position, original size, active direction, and an isResizing flag — and delegates the eight visual drag handles to a small memoized Resizer function component (src/resizer.tsx) that just wires onMouseDown/onTouchStart per direction. Rather than relying on React’s synthetic events for drag tracking, Resizable attaches mousemove/mouseup/touchmove/touchend listeners directly to window in componentDidMount, and mutates the wrapper’s DOM style imperatively via a ref during drag (wrapping updates in flushSync from react-dom to force synchronous, tear-free commits mid-drag). This keeps resize math — grid/snap clamping, aspect-ratio locking, boundary calculation — concentrated in a handful of instance methods (calculateNewMax, calculateNewMaxFromBoundary), which is easy to reason about but means the freeform, grid-snapped, aspect-locked, and bounded resize modes all share the same code path, so a change to the core clamping logic risks affecting all of them at once.
Tech Stack
Written in strict TypeScript with React as the only peer dependency (supporting 16.13 through 19), and zero runtime dependencies otherwise. Built with Rollup (rollup-plugin-typescript2, Babel plugins) into parallel ES5 and ESM (lib/index.es5.js, lib/index.js) bundles, distributed via files: ["lib"]. Package management and CI use pnpm; Storybook powers the live demo, deployed to GitHub Pages via gh-pages.
Code Quality
The project has a substantial Playwright component-test suite (src/index.spec.tsx, using @playwright/experimental-ct-react and sinon for spies) covering sizing modes, relative units (vw/vh/vmin/vmax), and callback behavior. tsconfig.json runs in strict mode, and CI (GitHub Actions) runs three separate jobs — lint, tsc, and test — on every push and PR. Linting still uses legacy tslint rather than eslint, which is dated but functional and paired with Prettier for formatting.
What Makes It Unique
Resizable wrapper components are a well-trodden pattern (react-rnd, interact.js, and similar libraries all solve the same problem), so the core idea isn’t novel. What distinguishes this implementation is its attention to detail: zero runtime dependencies, careful handling of relative units (percentages, vw/vh/vmin/vmax) for both size and min/max constraints rather than pixels only, a scale prop that corrects resize math when nested inside a CSS-transformed ancestor, and lockAspectRatioExtraWidth/Height for keeping media aspect-locked alongside a fixed-size sidebar or header — the kind of edge cases most hand-rolled resize implementations miss.
Used by 17 apps in this directory
Actual
Invoicing Finance
Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.
Colanode
Knowledge Management · Team Chat · Collaboration
Local-first, self-hosted workspace that combines real-time chat, Notion-style pages, and structured databases — all synced via CRDTs so you work offline without losing a keystroke.
Element Web
Team Chat · Collaboration
A polished, self-hostable Matrix client for secure, decentralized messaging and collaboration that puts your organization in full control of its data.
Grafana
Monitoring · Analytics
The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.
Helicone
Monitoring · AI Development · Analytics
An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.
ILLA Builder
Developer Tools · Low Code Platforms · No Code Platforms
Open-source low-code platform for building internal tools with drag-and-drop UI, reactive data bindings, and real-time collaboration.
Joplin
Note Taking
The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.
Laminar
AI Development · Monitoring
Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.
LearnHouse
Learning Management · CMS
Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.