骨架屏:从你的真实 DOM 生成像素级骨架屏。
Boneyard: Generate pixel-perfect skeleton screens from your real DOM

原始链接: https://github.com/0xGF/boneyard

## Boneyard.js: 自动骨架加载屏 Boneyard.js 通过**自动捕获现有 UI 的布局**来简化创建逼真的骨架加载屏——无需手动测量!它使用简单的 `` 组件支持 **React、Svelte 和 React Native**。 该过程涉及运行一个 CLI 工具 (`npx boneyard-js build`),它会: * **Web:** 打开无头浏览器以在定义的断点处截取你的应用快照。 * **React Native:** 直接在你的设备上扫描原生布局。 这会生成一个 `.bones.json` 文件,其中包含骨架定义。在你的应用入口点导入 `./bones/registry` 将激活骨架。 **主要特性:** * **零生产开销:** 骨架仅在加载期间使用。 * **可定制:** 配置颜色、动画(脉冲、闪烁、纯色)和断点。 * **跨平台:** 相同的 `.bones.json` 适用于 Web 和原生。 * **配置:** 使用 `boneyard.config.json` 进行全局设置,并由组件属性覆盖。

对不起。
相关文章

原文

Boneyard

Pixel-perfect skeleton loading screens, extracted from your real UI. No manual measurement, no hand-tuned placeholders.

Works with React, Svelte 5, and React Native.

import { Skeleton } from 'boneyard-js/react'

function BlogPage() {
  const { data, isLoading } = useFetch('/api/post')
  return (
    <Skeleton name="blog-card" loading={isLoading}>
      {data && <BlogCard data={data} />}
    </Skeleton>
  )
}
// Add once in your app entry
import './bones/registry'
<script>
  import Skeleton from 'boneyard-js/svelte'
  import '../bones/registry'
  let loading = true
</script>

<Skeleton name="card" {loading}>
  <Card />
</Skeleton>
import { Skeleton } from 'boneyard-js/native'

<Skeleton name="profile-card" loading={isLoading}>
  <ProfileCard />
</Skeleton>
npx boneyard-js build --native --out ./bones
# Open your app on device — bones capture automatically
// Add once in your app entry, then reload
import './bones/registry'

No browser needed. The --native flag scans the actual native layout on your device via the React fiber tree.

Web (React / Svelte): The CLI opens a headless browser, visits your app, finds every <Skeleton name="...">, and snapshots their layout at multiple breakpoints.

React Native: The <Skeleton> component auto-scans in dev mode when the CLI is running. It walks the fiber tree, measures views via UIManager, and sends bone data to the CLI. Zero overhead in production.

Both output the same .bones.json format — cross-platform compatible.

npx boneyard-js build                              # auto-detect dev server
npx boneyard-js build http://localhost:3000         # explicit URL
npx boneyard-js build --native --out ./bones        # React Native
npx boneyard-js build --breakpoints 390,820,1440    # custom breakpoints
npx boneyard-js build --force                       # skip incremental cache
Prop Type Default Description
loading boolean Show skeleton or real content
name string Unique name (generates name.bones.json)
color string rgba(0,0,0,0.08) Bone fill color
darkColor string rgba(255,255,255,0.06) Bone color in dark mode
animate 'pulse' | 'shimmer' | 'solid' 'pulse' Animation style
fixture ReactNode / Snippet Mock content for CLI capture (dev only)
initialBones ResponsiveBones Pass bones directly (overrides registry)
fallback ReactNode / Snippet Shown when loading but no bones available
{
  "breakpoints": [375, 768, 1280],
  "out": "./src/bones",
  "wait": 800,
  "color": "#e5e5e5",
  "animate": "pulse"
}

Save as boneyard.config.json. Per-component props override config values.

Import Use
boneyard-js snapshotBones, renderBones, computeLayout
boneyard-js/react React <Skeleton>
boneyard-js/native React Native <Skeleton>
boneyard-js/svelte Svelte <Skeleton>

Star History Chart

MIT

联系我们 contact @ memedata.com