Responsive

Boneyard captures your layout at multiple breakpoints automatically. One <Skeleton> component, one .bones.json file — the right skeleton is selected at runtime based on the container width.

Try it

This is a single <Skeleton name="responsive-product"> component. Resize it and watch it switch between the mobile, tablet, and desktop bone sets automatically.

680px
mobiletabletdesktop
my-app.com/products

Drag the handle to resize. The skeleton auto-switches at each breakpoint.

Same component, all breakpoints

The same <Skeleton name="responsive-product"> at three fixed widths. Each uses the same bones file — the component picks the matching breakpoint based on its container size.

220pxmobile
skeleton
400pxtablet
skeleton
640pxdesktop
skeleton
How it works

When you run npx boneyard-js build, Playwright visits your page at multiple breakpoints and snapshots the DOM at each one. If you have Tailwind, it auto-detects your breakpoints — 375, 640, 768, 1024, 1280, 1536px. Without Tailwind, it falls back to 375, 768, 1280px. All breakpoints are stored in a single .bones.json file.

At runtime, the <Skeleton> component uses a ResizeObserver to measure its container and picks the closest breakpoint. When the container resizes, it swaps to the matching skeleton automatically.

What the JSON looks like

Each .bones.json file contains all breakpoints in a single object. The x and w values are percentages of the container width, so they scale naturally.

responsive-product.bones.json
{
  "breakpoints": {
    "375": {
      "width": 220,
      "height": 341,
      "bones": [
        [0, 0, 100, 186, 6],
        // ... vertical stack
      ]
    },
    "768": { /* horizontal layout */ },
    "1280": { /* wide layout with button on right */ }
  }
}
Custom breakpoints

Tailwind breakpoints are auto-detected. Without Tailwind, the defaults are 375, 768, 1280. You can override them via boneyard.config.json or the CLI flag.

boneyard.config.json
{
  "breakpoints": [390, 820, 1440]
}

Or pass directly: npx boneyard-js build --breakpoints 390,820,1440

How breakpoint selection works
  • <Skeleton> measures its container width with ResizeObserver
  • Picks the largest breakpoint that fits (e.g., 500px container → uses 375px bones)
  • Updates automatically on resize — no re-render needed, just swaps the bone set
  • x and w are stored as percentages, so bones scale smoothly within a breakpoint range