@@ -71,6 +71,12 @@ Building skeleton screens is tedious. You eyeball pixel values, hardcode widths,
7171
7272![ Skeleton Inspector live capture] ( media/simulator_with_debugger.png )
7373
74+ <div align =" center " >
75+
76+ * Live capture —> simulator on the right, Skeleton Inspector DevTools panel on the left*
77+
78+ </div >
79+
7480<br />
7581
7682```
@@ -101,20 +107,12 @@ Your app (simulator / device) React Native DevTools
101107
1021081 . Wrap your component with ` <SkeletonCapture name="card"> `
1031092 . Open Skeleton Inspector in React Native DevTools
104- 3 . Click ** Capture** — real skeleton geometry is measured instantly
110+ 3 . Click ** ⬡ Capture** — real skeleton geometry is measured instantly
1051114 . Remove any unwanted skeletons by clicking the trash icon
106- 5 . Click ** Save** — ` card. skeletons.json` is written to your project
107- 6 . Import the JSON and pass it to ` <Skeleton initialSkeletons={…}> `
112+ 5 . Click ** ↓ Save Descriptor (.ts) ** for a cross-platform ` .ts ` file, or ** ↓ Save skeletons.json** for a static JSON snapshot
113+ 6 . The inspector shows the exact import + ` <Skeleton> ` snippet — copy and paste it
1081147 . Ship. Done.
109115
110- <div align =" center " >
111-
112- ![ Skeleton Inspector live capture] ( media/simulator_with_debugger.png )
113-
114- * Live capture — simulator on the left, Skeleton Inspector DevTools panel on the right*
115-
116- </div >
117-
118116---
119117
120118## Installation
@@ -129,13 +127,85 @@ yarn add react-native-auto-shimmer
129127
130128---
131129
130+ ## Two approaches to skeleton data
131+
132+ There are two ways to provide skeleton data to ` <Skeleton> ` . Choose based on your needs:
133+
134+ | | ** Descriptor** (TypeScript) ⭐ | ** Capture** (Inspector → JSON) |
135+ | ---| ---| ---|
136+ | How | Describe component structure in a ` .ts ` file | Inspector measures live layout, saves ` .skeletons.json ` |
137+ | Cross-platform | ✅ Perfect on every device & screen size | ⚠️ Vertical positions are device-specific |
138+ | Accuracy | Adapts at runtime to any container width | Pixel-perfect on the capture device |
139+ | Dynamic logic | ✅ ` Platform.OS ` , breakpoints, content length | ❌ Static JSON |
140+ | Auto-generate | ✅ Inspector generates a ` .ts ` starting point | ✅ Inspector saves directly |
141+ | Prop | ` descriptor={myDescriptor} ` | ` initialSkeletons={data} ` |
142+
143+ ** Use Descriptor** when you target multiple screen sizes, need Android precision, or want live adaptability — ** recommended** .
144+ ** Use JSON Capture** when you want a quick pixel-perfect result on a single device or to verify layout visually.
145+
146+ ---
147+
132148## Quick start
133149
134- ### 1. Wrap your screen
150+ ### Option A — Descriptor ⭐ (recommended, cross-platform)
151+
152+ The inspector can ** auto-generate** a ` .ts ` descriptor from your live layout. Click ** Save Descriptor (.ts)** after capturing — it writes a starting-point ` .ts ` file you can refine. Or write one by hand:
153+
154+ ``` tsx
155+ // card.skeletons.ts
156+ import type { SkeletonDescriptor } from ' react-native-auto-shimmer' ;
157+
158+ const cardDescriptor: SkeletonDescriptor = {
159+ display: ' flex' ,
160+ flexDirection: ' column' ,
161+ children: [
162+ { aspectRatio: 16 / 9 , borderRadius: 0 }, // hero image
163+ {
164+ display: ' flex' , flexDirection: ' column' ,
165+ padding: 16 , gap: 8 ,
166+ children: [
167+ { text: ' Article Title Here' , font: ' 700 18px Inter' , lineHeight: 26 },
168+ { text: ' Article body that may wrap across several lines of text.' , font: ' 14px Inter' , lineHeight: 20 },
169+ {
170+ display: ' flex' , flexDirection: ' row' , alignItems: ' center' , gap: 10 ,
171+ children: [
172+ { width: 32 , height: 32 , borderRadius: ' 50%' }, // avatar
173+ { text: ' Author Name' , font: ' 600 14px Inter' , lineHeight: 20 },
174+ ],
175+ },
176+ ],
177+ },
178+ ],
179+ };
180+
181+ export default cardDescriptor ;
182+ ```
183+
184+ ``` tsx
185+ // ArticleScreen.tsx
186+ import { Skeleton } from ' react-native-auto-shimmer' ;
187+ import cardDescriptor from ' ./skeletons/card.skeletons' ;
188+
189+ export function ArticleScreen() {
190+ const [loading, setLoading] = useState (true );
191+
192+ return (
193+ <Skeleton loading = { loading } descriptor = { cardDescriptor } style = { styles .card } >
194+ <ArticleCard />
195+ </Skeleton >
196+ );
197+ }
198+ ```
199+
200+ > ` <Skeleton> ` measures its own width via ` onLayout ` and runs ` computeLayout() ` automatically — no manual width tracking needed. Works identically on iOS and Android at any screen size.
201+
202+ ### Option B — JSON Capture (pixel-perfect on capture device)
203+
204+ Run the [ Skeleton Inspector] ( #capturing-skeletons-with-skeleton-inspector ) , click ** Capture → Save skeletons.json** , then use the generated file:
135205
136206``` tsx
137207import { Skeleton } from ' react-native-auto-shimmer' ;
138- import cardSkeletons from ' ./skeletons/card.skeletons.json' ; // added after first capture
208+ import cardSkeletons from ' ./skeletons/card.skeletons.json' ; // generated by inspector
139209
140210export function ArticleScreen() {
141211 const [loading, setLoading] = useState (true );
@@ -148,7 +218,7 @@ export function ArticleScreen() {
148218}
149219```
150220
151- Before you've captured skeletons , ` <Skeleton> ` shows a blank fallback. The next section walks through capturing the real geometry .
221+ Before you've set up skeleton data , ` <Skeleton> ` shows a blank fallback. The next section walks through the inspector capture workflow .
152222
153223---
154224
@@ -246,12 +316,22 @@ The panel draws every skeleton with a numbered colour overlay and a data table b
246316
247317### Step 9 — Save
248318
249- Click ** ↓ Save skeleton.json** . The file lands in the Output Directory shown in the sidebar (default ` src/skeletons ` ):
319+ Two buttons appear after capture:
320+
321+ | Button | Output | Best for |
322+ | ---| ---| ---|
323+ | ** ↓ Save Descriptor (.ts)** ⭐ | ` card.skeletons.ts ` | Cross-platform, all Android sizes |
324+ | ** ↓ Save skeletons.json** | ` card.skeletons.json ` | Quick snapshot, single device |
325+
326+ Files land in the Output Directory shown in the sidebar (default ` src/skeletons ` ):
250327
251328```
252- src/skeletons/card.skeletons.json ✓
329+ src/skeletons/card.skeletons.ts ✓ ← descriptor (recommended)
330+ src/skeletons/card.skeletons.json ✓ ← json snapshot
253331```
254332
333+ After saving, the inspector shows a ** ready-to-paste code snippet** with the exact import line and ` <Skeleton> ` usage — just copy and drop it into your screen file.
334+
255335---
256336
257337## Using saved skeletons
@@ -558,7 +638,7 @@ We welcome contributions of all sizes — bug fixes, new features, docs improvem
558638
559639## License
560640
561- MIT © [ Numan] ( https://github.com/shobbak )
641+ MIT © [ Numan] ( https://github.com/numandev1 )
562642
563643---
564644
0 commit comments