Getting Hequalizer running takes three steps: mark the elements you want to equalize in HTML, create an instance in JavaScript that targets those elements by handle, and write a CSS rule that consumes the variable Hequalizer sets. The entire workflow — from zero to equalized heights — is covered below.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.
Mark elements in HTML
Add a The handle value (
data-hequalizer attribute to every element that should share a height. The attribute value is the handle — a lowercase slug string that uniquely identifies this group on the page.index.html
"card-title" here) must be a lowercase slug — letters, numbers, and hyphens only. Every element in this group shares the same data-hequalizer value, and that value must exactly match the string you pass to the Hequalizer constructor in the next step.Create a Hequalizer instance
After the DOM has been parsed, instantiate When the constructor runs, Hequalizer:
Hequalizer with the same handle string you used in the HTML.main.js
- Validates the handle: throws if it is missing, throws if it does not match the required slug format (
/^[a-z0-9]+(?:-[a-z0-9]+)*$/), and throws if the same handle is already in use by another active instance. - Runs
document.querySelectorAll('[data-hequalizer="card-title"]')to collect the elements. - Registers the instance in the static
Hequalizer.instancesmap. - Waits for
document.fonts.readyso web fonts are fully loaded andoffsetHeightmeasurements are accurate. - Calls
init()automatically (viadocument.fonts.ready) — which calculates the maximum height, writes the CSS variable, and starts the resize listener and MutationObservers. You rarely need to callinit()manually.
Because Hequalizer defers to
document.fonts.ready, the initial calculation always reflects true rendered heights — even when custom fonts cause text to reflow after the DOM loads.Consume the CSS variable
Hequalizer writes the calculated height as an inline CSS custom property named
--height on each element. Add a CSS rule that uses that variable however your design requires.styles.css
--height is the default variable name. Hequalizer sets it as an inline style (e.g. style="--height: 64px;") on every element in the group after measuring the tallest one.You can override the variable name per instance or per breakpoint using the cssVariable option:What happens next
Onceinit() completes, Hequalizer continues to maintain equal heights automatically without any further intervention.
Resize handling — A window resize listener is registered and remains active for the lifetime of the instance. On every resize event, Hequalizer re-evaluates the active breakpoint, recalculates the maximum height, and updates the CSS variable on all elements. You can add a debounce value (in milliseconds) to throttle recalculation during rapid resize events.
Content change watching — Each element in the group is observed by its own MutationObserver configured to watch childList, subtree, and characterData. If the text or child nodes of any element change — for example because dynamic content is injected — Hequalizer waits 20 ms and then recalculates automatically, emitting a hequalizer:card-title:change event when done.
Instance registry — The instance is stored in a static Map keyed by handle. You do not need to hold a variable reference to interact with it later:
Add Responsive Breakpoints
Learn how to configure different
columns, cssVariable, and debounce values at specific viewport widths using the responsive option.Full Constructor Reference
Explore every option available in the
Hequalizer constructor, including all default values, valid input formats, and the complete instance API.