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.
Preview
Section titled “Preview”<nana-resize-observer>
<div>Resizable content</div>
</nana-resize-observer> Installation
Section titled “Installation”npm install @nana-tec/ui-componentsImport
Section titled “Import”
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.
Basic usage
Section titled “Basic usage”<nana-resize-observer> <div>Resizable content</div></nana-resize-observer>Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
box | box | ResizeObserverBoxOptions | 'content-box' | Which box model to observe |
disabled | disabled | boolean | false | Stop observing |
Events
| Event | Description |
|---|---|
nana-resize | Fired on resize (detail.entries, detail.contentRect) |
Slots
| Slot | Description |
|---|---|
(default) | The content to observe |