Lazy
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.
<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. Thev-intersectdirective 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.
- modelValuebooleanfalse
- Controls visibility. Once set to true (either programmatically or via the IntersectionObserver), the children are mounted and stay mounted.
- optionsIntersectionObserverInit{ root: undefined, rootMargin: undefined, threshold: undefined }
- IntersectionObserver options passed to the v-intersect directive. Controls root element, margin and threshold.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- heightnumber | string
- Placeholder height before the content is loaded. Helps IntersectionObserver detect the element.
- maxHeightnumber | string
- Maximum placeholder height.
- maxWidthnumber | string
- minHeightnumber | string
- Minimum placeholder height.
- minWidthnumber | string
- widthnumber | string
- Placeholder width before the content is loaded.
- tagstring'div'
- Root HTML element tag.
- 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:modelValueany
- 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
Controlled (v-model)
Custom observer options