How It Works
Height Harmony automatically syncs element heights using the most efficient browser APIs available.
Step 01
Inline heights are cleared and natural scrollHeights are measured in a single synchronous layout pass to avoid reflows.
Step 02
The tallest element in the group is identified. All measurements happen in one batch read to minimize layout thrashing.
Step 03
ResizeObserver and MutationObserver keep heights in sync automatically — no window resize listeners needed.
Interactive Demo
All cards in this grid share equal heights automatically. Try adding cards, toggling the utility on/off, or resizing the window.
Why Height Harmony
Everything you need — nothing you don't.
Automatically re-syncs when any element changes size. No window resize listeners needed.
Watches the DOM for new elements. Works seamlessly with AJAX, infinite scroll, and dynamic content.
Disable equalizing below a viewport width — let mobile layouts stack naturally.
refresh() to re-trigger manually, destroy() to tear down
observers and restore natural heights.
All height reads happen in a single synchronous batch. Writes follow immediately. No interleaved read/write cycles.
Works as an ES import, CommonJS require, or plain script tag. No bundler required.
Usage
Drop it in however you prefer.
import heightHarmony from 'height-harmony';
// Equalize heights of all matching elements
heightHarmony('.card');
// Returns an instance with refresh() and destroy()
const hh = heightHarmony('.feature-box');
hh.refresh(); // manually re-trigger
hh.destroy(); // remove observers & restore heights