03-api-reference

All docs

API Reference

AutoSkeleton Component

The main component exported from the package.

tsx
import { AutoSkeleton } from 'auto-skeleton-react';

Props

PropTypeRequiredDescription
loadingbooleanYesControls skeleton visibility. true shows skeleton, false shows content.
childrenReact.ReactNodeYesThe content to wrap. Rendered hidden during loading for measurement.
configPartial<SkeletonConfig>NoOverride default configuration options.

Usage

tsx
<AutoSkeleton loading={isLoading} config={{ animation: 'pulse' }}>  <YourComponent /></AutoSkeleton>

SkeletonConfig

Configuration interface for customizing skeleton behavior and appearance.

tsx
import type { SkeletonConfig } from 'auto-skeleton-react';

Properties

PropertyTypeDefaultDescription
animation`'pulse' \'shimmer' \'none'`'pulse'Animation applied to skeleton elements
baseColorstring'#e0e0e0'Background color of skeleton blocks
highlightColorstring'#f5f5f5'Highlight color for animations
borderRadiusnumber4Border radius (px) for skeleton blocks
minTextHeightnumber12Minimum height (px) to classify as text
minImageSizenumber32Minimum dimension (px) to classify as image
iconMaxSizenumber48Maximum dimension (px) for icon detection
maxDepthnumber10Maximum DOM traversal depth
ignoreSelectorsstring[]['.no-skeleton', '[data-skeleton-ignore]']CSS selectors to exclude from skeleton

Example

tsx
const config: Partial<SkeletonConfig> = {  animation: 'pulse',  baseColor: '#f0f0f0',  borderRadius: 8,  maxDepth: 15,  ignoreSelectors: ['.no-skeleton', '[data-skeleton-ignore]', '.custom-ignore'],};<AutoSkeleton loading={true} config={config}>  <MyComponent /></AutoSkeleton>

SkeletonNode

Represents a node in the skeleton blueprint tree. Useful for advanced debugging or custom renderers.

tsx
import type { SkeletonNode } from 'auto-skeleton-react';

Properties

PropertyTypeDescription
typestringElement role (see types below)
rect{ x, y, width, height }Position and dimensions
borderRadius?numberBorder radius
display?stringCSS display value
gap?stringCSS gap value
children?SkeletonNode[]Child nodes
lines?numberLine count (multi-line text)
tagName?stringHTML tag name (table elements)
passthrough?booleanWhether to render original HTML
passthroughHtml?stringOriginal HTML content
preservedStyles?objectCSS styles preserved from original

Node Types

TypeDescription
textText content
imageImages and background images
iconSmall square SVGs/icons
buttonInteractive buttons
inputForm inputs, textareas, selects
containerLayout wrapper with children
skipTiny spacer elements (not rendered)
passthroughPreserved original HTML
tableHTML table element
theadTable head
tbodyTable body
trTable row
thTable header cell
tdTable data cell

Data Attributes

These HTML attributes control skeleton behavior on specific elements.

AttributeEffect
data-no-skeletonElement stays visible during loading (not skeletonized)
data-skeleton-ignoreElement is skipped entirely from skeleton generation
data-skeleton-roleForces a specific skeleton type (e.g., "text", "image", "button")

CSS Classes

ClassEffect
.no-skeletonSame as data-skeleton-ignore — element skipped from skeleton

See Opt-Out and Escape Hatches for details.