npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@n-ivan/react-justified-gallery

v2.0.0

Published

A React component for creating justified image galleries

Readme

react-justified-gallery

A React component for creating beautiful justified image galleries with CSS flexbox layout.

Features

  • Perfect Justification - Images fill the full container width while preserving aspect ratios
  • Fully Responsive - Pure CSS handles resize automatically
  • Flexible Rendering - Custom render prop for complete control over image display
  • SSR-Friendly - No client-side measurement needed
  • Zero Re-renders - No state changes on container resize

Installation

npm install @n-ivan/react-justified-gallery

Quick Start

import { JustifiedGallery } from '@n-ivan/react-justified-gallery';

const images = [
  [
    { src: 'image1.jpg', width: 1920, height: 1080 },
    { src: 'image2.jpg', width: 800, height: 600 }
  ],
  [
    { src: 'image3.jpg', width: 1200, height: 1200 }
  ]
];

function App() {
  return <JustifiedGallery images={images} gap={8} />;
}

Data Structure

The gallery accepts a 2D array where each inner array represents a row of images:

type ImageData = {
  src: string;
  width: number;  // Original width in pixels
  height: number; // Original height in pixels
  alt?: string;   // Optional alt text
  [key: string]: unknown; // Any additional properties
};

type GalleryData = ImageData[][];

API Reference

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | images | ImageData[][] | required | 2D array of image data | | gap | number | 8 | Gap between images in pixels | | renderImage | function | - | Custom render function for images | | lazyLoad | boolean | true | Enable native lazy loading | | onImageLoad | function | - | Callback when image loads | | onImageError | function | - | Callback when image fails | | containerStyle | CSSProperties | - | Styles for gallery container | | rowStyle | CSSProperties | - | Styles for each row |

RenderImage Props

When using the renderImage prop, you receive the following properties:

interface RenderImageProps {
  image: ImageData;  // Original image data
  rowIndex: number;  // Row index (0-based)
  imageIndex: number; // Image index in row (0-based)
}

The wrapper div already has the correct flex and aspect-ratio styles applied, so your custom content just needs to fill width: 100% and height: 100%.

Development

Install Dependencies

npm install

Run Demo

npm run demo

Run Tests

npm test

Build Library

npm run build

Type Check

npm run lint

TypeScript

Full TypeScript support with exported types:

import type {
  JustifiedGalleryProps,
  ImageData,
  RenderImageProps
} from 'react-justified-gallery';

Browser Support

Modern browsers with support for:

  • CSS aspect-ratio property (Chrome 88+, Firefox 89+, Safari 15+, Edge 88+)
  • CSS Flexbox
  • React 18+

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.