Installation
Copy pageInstall
Section titled “Install”npm install dotquiltbun add dotquiltFor React, add the adapter too:
npm install @dotquilt/reactRegister the components
Section titled “Register the components”Each component has its own entry point, so you only ship what you use. Register them once, before they appear on the page.
import { registerLoadingRegion } from 'dotquilt/region';import { registerSkeletonText } from 'dotquilt/skeleton';
registerLoadingRegion();registerSkeletonText();The React components register themselves. Import them from the adapter:
import { LoadingRegion, SkeletonText } from '@dotquilt/react';To register every component at once, call registerAll() from dotquilt/register-all.
LoadingRegion loads its reveal animation on its own, the first time a region shows its placeholder, so it doesn’t weigh on the first page load. Bundlers such as Vite and webpack split it into its own file. If the data arrives before that file has loaded, that one handover uses the simpler dissolve.
Show a placeholder
Section titled “Show a placeholder”<dotquilt-region state="pending" aria-label="Quarterly revenue"> <dotquilt-skeleton-text slot="placeholder" lines="3"></dotquilt-skeleton-text> <article>…your content…</article></dotquilt-region>When the data arrives, fill in your content and set the state:
const region = document.querySelector('dotquilt-region');region?.update({ state: 'ready' });<LoadingRegion state={data ? 'ready' : 'pending'} aria-label="Quarterly revenue" placeholder={<SkeletonText lines={3} />}> <article>…your content…</article></LoadingRegion>Give each region a label, so assistive technology can name what is loading.
For a complete component with a real request, errors and stale answers, see the usage example on the Skeleton page.