ClientOnly

Utilities & Providers
stable

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

Anatomie

Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.

Anatomy of OrigamClientOnlySchematic showing the SSR vs client render paths of OrigamClientOnly. SSR (isMounted = false) #fallback slot (or placeholder tag) Client (isMounted = true) #default slot (your content) 1 2
Anatomy of <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

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.

placeholderTag
string
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.
placeholderClass
string
CSS class applied to the placeholder element. Pair with placeholderTag to reserve exact dimensions matching the client render.

API

Slots

Emplacements de contenu exposés par ce composant.

#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

Accessibilité

Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.

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.

Interactif

Playground

Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.

Rendu de l’aperçu en cours…

Usage

Exemples

Extraits de code prêts à coller dans vos templates.

Basic usage

vue

Layout-preserving placeholder

vue