Skip to content

LazyChart

Shared Components

Defer mounting chart content until it approaches the viewport.

Viewport-triggered contentReserved placeholder height
Open preview

Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.

Usage

Wrap chart content in LazyChart to postpone mounting until it approaches the viewport. Match height to the eventual chart to limit layout movement. This defers rendering; use dynamic import separately to defer downloading chart code.

Import
import { LazyChart } from "@dashboardpack/core/components/shared/lazy-chart";

Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.

API reference

Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.

LazyChart props
PropType / DefaultDescription
childrenReactNode

Default: required

Chart or expensive visual content.
heightnumber

Default: 320

Skeleton height in pixels before mounting.
classNamestring

Default: —

Extend the observer container styles.

Build with these too