
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
@kaliber/use-element-size
Advanced tools
Determines the width and height in pixels of an element through ResizeObserver
Read the height and width of an element
Determines the width and height (in pixels) of an element through ResizeObserver. This is more performant and easier to use than listening to a resize event and reading the element's size through getBoundingClientRect or getComputedStyle, which run on the main thread and can trash layout. Note that the hook is only updated when the element's size changes, not when the window's size changes.
This library reports the border-box size, which includes the elements padding and border.
yarn add @kaliber/use-element-size
import { useElementSize } from '@kaliber/use-element-size'
function Component() {
const { size: { width, height }, ref: elementRef } = useElementSize()
return <div ref={elementRef}>{width}px × {height}px</div>
}
.component {
overflow: hidden;
transition: height 0.5s;
}
import { useElementSize } from '@kaliber/use-element-size'
export function Expand({ children, expanded }) {
const { size: { height }, ref: innerRef } = useElementSize()
return (
<div
className={styles.component}
style={{ height: expanded ? height + 'px' : '0px' }}
>
<div ref={innerRef}>
{children}
</div>
</div>
)
}

This library is intended for internal use, we provide no support, use at your own risk. It does not import React, but expects it to be provided, which @kaliber/build can handle for you.
This library is not transpiled.
FAQs
Determines the width and height in pixels of an element through ResizeObserver
The npm package @kaliber/use-element-size receives a total of 33 weekly downloads. As such, @kaliber/use-element-size popularity was classified as not popular.
We found that @kaliber/use-element-size demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.