We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

LazyImage Component

The LazyImage component provides an enhanced image loading experience with support for skeleton loading states, thumbnail previews, and intelligent preloading. Perfect for optimizing image loading performance while maintaining a smooth user experience.

  • Check Circle

    Smart Preloading: Customizable preload distance for optimized loading

  • Check Circle

    Loading States: Built-in skeleton and thumbnail loading options

  • Check Circle

    Flexible Integration: Works with both local and remote images

Create a simple lazy-loaded image:

---
import { LazyImage } from '@/components/NST-components/UI';
import myImage from '@/assets/images/example.jpg';
---
<LazyImage
imageProps={{
src: myImage,
alt: 'Example image',
width: 800,
height: 600,
}}
/>

Show a skeleton loading state while the image loads:

<LazyImage
variant="skeleton"
imageProps={{
src: myImage,
alt: "Example with skeleton",
width: 800,
height: 600
}}
/>

Display a low-resolution thumbnail while loading the main image:

<LazyImage
variant="thumbnail"
imageProps={{
src: highResImage,
alt: "High resolution image",
width: 1200,
height: 800
}}
thumbnailProps={{
src: lowResImage,
alt: "Low resolution preview",
width: 120,
height: 80
}}
/>

Configure preloading distance to start loading images before they enter the viewport:

<LazyImage
preloadDistance={200} // Start loading 200px before image enters viewport
imageProps={{
src: myImage,
alt: "Preloaded image",
width: 800,
height: 600
}}
/>
LazyImage Component Props extends <div> HTMLElement
Prop Type Default Description
imageProps ComponentProps<typeof Image> - Props for the main image
variant skeleton | thumbnail Loading state variant
skeletonProps ComponentProps<typeof Skeleton> Props for skeleton loader
thumbnailProps ComponentProps<typeof Image> Props for thumbnail image
preloadDistance number Distance in pixels to start preloading

Limited Time Launch Sale

Optimize your image loading experience with our LazyImage component. Get started with our AstroJS starter template today!

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes