Hequalizer’s handle-based API makes it straightforward to apply height equalization to almost any layout pattern. The examples below cover the most common scenarios — each one shows the HTML markup, the JavaScript initialization, and the CSS needed to consume the generated custom property.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/soyleninjs/hequalizer/llms.txt
Use this file to discover all available pages before exploring further.
Responsive Grid
Card grids are the most frequent use case for Hequalizer. When a grid switches between three columns on desktop, two on tablet, and one on mobile, the column grouping must match the visual layout at every breakpoint — otherwise elements in separate visual rows would share a height calculation that doesn’t apply to them.Add data-hequalizer to your heading elements
Mark every heading that belongs to the same equalization group with a matching
data-hequalizer attribute. The value must be a lowercase slug — the same string you’ll pass to the constructor.index.html
Initialize Hequalizer with matching column counts
Pass Hequalizer sorts breakpoints from smallest to largest internally and picks the first one where
columns: 3 to match the three-column desktop layout. The responsive map mirrors the CSS breakpoints — 1024 switches to two columns and 640 drops to one column, which automatically clears all CSS variables so mobile titles use their natural height.main.js
window.innerWidth <= breakpoint. If no breakpoint matches, it falls back to the top-level columns: 3 default.Multiple Independent Groups
A product card typically has at least two elements that need separate equalization: the title and the description. Each group requires its own handle and — to avoid conflicts — its own CSS custom property name.Create one instance per group with custom variable names
Each instance manages its own set of elements and writes to its own CSS variable. Providing explicit
cssVariable names avoids both groups writing to the default --height property and overwriting each other.main.js
You can create as many independent groups as your layout needs. Each instance tracks its own elements, breakpoints, and CSS variable — they never interfere with one another. Retrieve any active instance later with
window.Hequalizer.getInstance('product-title') without keeping a reference yourself.Carousel / Slider with Dynamic Slides
A carousel that lazy-loads additional slides presents two challenges: the resize debounce must be generous enough not to thrash recalculations during drag gestures, and the instance must re-query the DOM after new slides are injected.Initialize with a debounce suitable for carousel interactions
main.js
columns: 'all' equalizes every slide in the carousel to the same height regardless of how many are visible at once. The debounce: 100 value delays the resize recalculation by 100 ms, which prevents excessive layout thrashing when the user resizes the browser or the carousel adjusts its own dimensions.Listen for the init event to confirm equalization
main.js
event.detail.instance is the live Hequalizer instance. values holds the single maximum height (a Number) when columns is 'all', or an array of per-row maximums when columns is a number.Call refreshElements() after dynamic content loads
When the carousel appends new slides to the DOM, Hequalizer’s existing
MutationObserver watches content changes inside already-tracked elements — it does not detect brand-new elements added outside those nodes. Call refreshElements() explicitly after the carousel injects new slides.main.js
refreshElements() re-runs document.querySelectorAll('[data-hequalizer="slide-title"]'), re-attaches observers to any new elements, recalculates heights, and emits a hequalizer:slide-title:refresh event.Disable Equalization on Mobile
On a single-column mobile layout, all cards stack vertically and share no row with neighbours — height equalization is unnecessary and adds unhelpfulmin-height constraints. Setting columns: 1 (or any value ≤ 1) at a breakpoint tells Hequalizer to clean up its CSS variables and state classes without destroying the instance.
main.js
- Removes the
--heightinline custom property from every element. - Removes all state classes (
height-calculated,height-zero,height-calculating). - Skips the height measurement step — no
offsetHeightreads and no CSS variable assignment occur.
columns: 3 default and resumes equalizing automatically — no manual intervention needed.