Lazy

Layout & Structure
stable

Defers the mounting of its children until the placeholder enters the viewport. Uses IntersectionObserver (v-intersect directive) with an optional fade-in transition.

Structure

Anatomy

Visual breakdown of the component's internal structure with BEM class call-outs.

Anatomy of OrigamLazySchematic of the Lazy component in its two states: placeholder and revealed. placeholder (min-height applied, children not mounted) revealed (children mounted + fade transition) 1 2
Anatomy of <origam-lazy> — ① placeholder state (children unmounted, min-height reserves space for IntersectionObserver) → ② revealed state (children mounted with transition).
1.origam-lazy (placeholder)
While isActive=false, the root element is an empty block with the configured dimensions. The v-intersect directive watches it.
2.origam-lazy (revealed)
Once isActive=true, the default slot is rendered inside an <origam-transition> (OrigamFade by default). The element is never hidden again.

API

Props

All props accepted by this component, with their type, default value and description.

modelValue
boolean
false
Controls visibility. Once set to true (either programmatically or via the IntersectionObserver), the children are mounted and stay mounted.
options
IntersectionObserverInit
{ root: undefined, rootMargin: undefined, threshold: undefined }
IntersectionObserver options passed to the v-intersect directive. Controls root element, margin and threshold.
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
height
number | string
Placeholder height before the content is loaded. Helps IntersectionObserver detect the element.
maxHeight
number | string
Maximum placeholder height.
maxWidth
number | string
minHeight
number | string
Minimum placeholder height.
minWidth
number | string
width
number | string
Placeholder width before the content is loaded.
tag
string
'div'
Root HTML element tag.
transition
{ component: OrigamFade }
Transition to apply when the slot content is revealed. Defaults to OrigamFade. Pass null to disable.

API

Slots

Content slots exposed by this component.

#default
Content to render once the element enters the viewport. Wrapped in the configured transition.

API

Emits

Events emitted by this component.

@update:modelValue
any
Emitted when the IntersectionObserver fires and the element becomes visible. Payload is always true (component only mounts once).

API

Exposed members

Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.

<T extends object>(props: T, exclude?: string[]) => Partial<T>
Utility to forward a filtered subset of props to a child.
Ref<string>
Reactive CSS string generated by useStyle.
string
Unique style-sheet ID for this instance.
() => void
Injects the computed style sheet. Called automatically on mount.
() => void
Removes the injected style sheet. Called automatically on unmount.
Ref<boolean>
True once the style sheet has been injected into the DOM.

Customisation

CSS variables

CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.

Duration of the reveal transition (OrigamFade).
Easing of the reveal transition.
Minimum height of the placeholder zone so the IntersectionObserver has something to detect.
Background color of the placeholder zone (visible only before reveal).

Inclusion

Accessibility

ARIA roles, keyboard navigation and focus management. Sourced from the real component template.

Notes

  • While the content is not yet revealed, the root element carries <code>aria-busy="true"</code>. This signals to assistive technologies that the region is still loading.
  • OrigamLazy relies on IntersectionObserver. Ensure placeholder dimensions are set (min-height / height) so the browser can observe a non-zero element. A zero-size element may never intersect and the content would never mount.
  • The default OrigamFade transition respects prefers-reduced-motion: reduce — pass transition="null" to fully disable animation.

Interactive

Playground

Edit props live and see the component update in real time. The generated code snippet updates as you change values.

Rendering the live preview…

Usage

Examples

Ready-to-paste code snippets for your templates.

Basic lazy load

vue

Controlled (v-model)

vue

Custom observer options

vue