ClientOnly
Wrapper that renders its default slot ONLY after hydration on the client. On the server a configurable placeholder element (or the #fallback slot) is rendered instead, preventing hydration mismatches for client-only content.
Structure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<origam-client-only> — two render paths: server (fallback/placeholder) and client (default slot after onMounted).- 1#fallback / placeholderTag
- Rendered on the server and during first client paint. Either the #fallback slot content or a generated
element (aria-hidden="true"). - 2#default
- Rendered only after onMounted fires on the client (isMounted ref flips to true). Completely absent from SSR output.
API
Props
All props accepted by this component, with their type, default value and description.
- placeholderTagstring
- HTML tag used for the SSR placeholder when no #fallback slot is provided. Defaults to undefined — SSR output is completely empty (perf win). Set to 'div' or 'span' when you need to reserve layout space to avoid cumulative layout shift.
- placeholderClassstring
- CSS class applied to the placeholder element. Pair with placeholderTag to reserve exact dimensions matching the client render.
API
Slots
Content slots exposed by this component.
- #default
- Content rendered only on the client, after hydration. Not executed on the server.
- #fallback
- Content rendered on the server and during the initial client hydration. Replaces the auto-generated placeholder element.
Inclusion
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
Notes
- The auto-generated placeholder element carries aria-hidden="true" so it is invisible to assistive technologies. Only provide a placeholder that is purely decorative (skeleton, shimmer).
- If the #fallback slot contains meaningful content (e.g. "Loading chart…"), ensure it is visible to screen readers (do not add aria-hidden).
- OrigamClientOnly prevents hydration mismatches for content that relies on browser APIs (window, document, canvas, WebGL). Use it for charts, maps, canvas-based components and anything that reads window dimensions on mount.
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 usage
Layout-preserving placeholder