Preact
Native Preact integration — uses preact/hooks directly, no preact/compat needed. Same API as React, smaller bundle.
1. Install
npm install boneyard-js2. Add the component
import { Skeleton } from 'boneyard-js/preact'
import './bones/registry'
function BlogPage() {
const { data, isLoading } = useFetch('/api/post')
return (
<Skeleton name="blog-card" loading={isLoading}>
{data && <BlogCard data={data} />}
</Skeleton>
)
}3. Generate bones
npx boneyard-js buildAuto-detects your Preact dev server and captures all named skeletons.
4. Import the registry
// Add once in your app entry (e.g. main.tsx)
import './bones/registry'This import is required.Without it, skeletons won't render — the component needs the registry to resolve bone data by name.
| Prop | Type | Default | Description |
|---|---|---|---|
| loading | boolean | required | Show skeleton or children |
| name | string | — | Resolve bones from registry by name |
| initialBones | ResponsiveBones | — | Pass bones directly (overrides registry) |
| color | string | rgba(0,0,0,0.08) | Bone color in light mode |
| darkColor | string | rgba(255,255,255,0.06) | Bone color in dark mode |
| animate | 'pulse' | 'shimmer' | 'solid' | pulse | Animation style (also accepts true/false) |
| stagger | number | boolean | false | Stagger delay between bones in ms (true = 80ms) |
| transition | number | boolean | false | Fade out duration in ms when loading ends (true = 300ms) |
| boneClass | string | — | CSS class applied to each bone element |
| className | string | — | CSS class on the container |
| fixture | ComponentChildren | — | Mock content for CLI capture (dev only) |
| fallback | ComponentChildren | — | Shown when loading but no bones available |
| snapshotConfig | SnapshotConfig | — | Controls bone extraction during CLI capture |
The Vite plugin auto-detects Preact and generates the registry with the correct imports. No extra configuration needed:
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
import { boneyardPlugin } from 'boneyard-js/vite'
export default defineConfig({
plugins: [preact(), boneyardPlugin()]
})Bones are captured on dev server start and re-captured on every HMR update.
Auto-detects via .dark class on <html> or any parent element (Tailwind convention), and prefers-color-scheme media query. Uses darkColor when dark mode is active.
| Value | Effect |
|---|---|
| 'pulse' | Fades a lighter overlay in and out (1.8s cycle) |
| 'shimmer' | Sweeps a gradient highlight across each bone (2.4s cycle) |
| 'solid' | Static — no animation |
| true / false | true = pulse, false = solid |
Set defaults for all skeletons with configureBoneyard():
import { configureBoneyard } from 'boneyard-js/preact'
configureBoneyard({
color: '#e5e5e5',
darkColor: 'rgba(255,255,255,0.08)',
animate: 'shimmer',
})Per-component props override global defaults.
See Install → Config file for the full boneyard.config.json reference. Works with all frameworks.
Next steps
- See Getting Started for the full web setup walkthrough
- See Output to understand the .bones.json format
- See CLI & Props Reference for all flags and options