Skeleton Screen Usage Guide
Info
The skeleton screen effectively reduces the initial page or page switching white screen time and improves visual continuity and loading experience.
Applicable Scenarios
- Pages where the first screen has a lot of data and API responses have certain latency.
- Page switching shows obvious blank or flashing; want a more natural transition.
- Need placeholder display linked with Light / Dark theme.
Requirements
- Base library version
>=2.27.2 - @ray-js/cli version
>=1.6.30 - Developer tool (IDE) version
>=0.9.0
Basic Workflow
Step 1: Generate snapshot skeleton code in IDE
- Open the skeleton preview tool in IDE.
- Adjust parameters until satisfied then click "Copy Code".
Parameter Description
- Element Range: identifies page node hierarchy and controls generation scope.
- Ignore Element Size: filters very small elements to avoid meaningless placeholders.
- Extract Text Elements: converts text into unified styled placeholder blocks for consistent look.
- Ignore Inline Elements: excludes inline elements with uncertain width/height to avoid misalignment.
- Snapshot Background Color: configure background placeholder colors for light / dark theme.
- Custom Navigation Bar: if page uses
navigationStyle = custom, check this to adapt the nav height offset. - Keep Native Style: use the element's own background color as placeholder (otherwise unified skeleton color).
- Overlay Opacity: adjusts depth effect after stacking color blocks.
Step 2: Create the skeleton snapshot file
Create a pageName.snapshot.html file under the corresponding page folder and paste the copied code from Step 1.
Directory Example:
Step 3: Build & Verify
Execute the normal build process. In the output directory dist check whether the corresponding page contains *.snapshot.html:
Open the MiniApp page: before business logic and real content render, the skeleton placeholder layer should appear first and then naturally transition to real content.
Skeleton Template Example
Dark Theme Adaptation Example
Custom Navigation Bar Offset Example
Parameter Explanation
When using manual mode, you can manually remove in page lifecycle: