Skip to content
Nana UI

Utilities

Resize Observer

Watches its slotted content for size changes via ResizeObserver and emits nana-resize with the observer entries. Useful for building container-aware layouts and reacting to element resizes without wiring observers by hand.

View .md Download
Resizable content
npm install @nana-tec/ui-components

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/resize-observer";

Copied in with npx @nana-tec/ui add resize-observer? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<nana-resize-observer>
<div>Resizable content</div>
</nana-resize-observer>

Properties

PropertyAttributeTypeDefaultDescription
boxboxResizeObserverBoxOptions'content-box'Which box model to observe
disableddisabledbooleanfalseStop observing

Events

EventDescription
nana-resizeFired on resize (detail.entries, detail.contentRect)

Slots

SlotDescription
(default)The content to observe