mosaicgallery
v0.6.0
Published
A modern, responsive, zero-dependency image gallery built with TypeScript and Vite.
Maintainers
Readme
Mosaic Gallery 🚀
A modern, responsive, zero-dependency image gallery built with TypeScript and Vite.
- Lightweight, fast and zero-dependency
- Fully customizable
- Supports two different layouts
Mosaic Gallery is a modern browser library written in TypeScript and built with Vite. It turns a simple list of images into an elegant gallery view. It requires zero dependencies and is built on modern browser features with responsiveness and performance in mind. There are two different layouts available, each with a multitude of configuration options to address any use case.
In addition, the look and feel of the gallery can be customized with custom css rules.

Installation
MosaicGallery can be installed from npmjs or downloaded from the latest Gitlab release.
It is bundled as a legacy UMD file (mosaic-gallery.umd.cjs) and a modern ES module (mosaic-gallery.js).
It provides full TypeScript type information (mosaic-gallery.d.ts).
Don't forget to also include the CSS stylesheet (mosaic-gallery.css).
Tests
MosaicGallery uses vitest for testing. It includes unit tests for testing the basic layout calculations and full fledged browser tests to test the responsive layout logic. In addition, test coverage is calculated as well.
After all tests have been run, a HTML report of the test coverage is generated in coverage/index.html.
To run the browser tests, playwright and the its chromium browser must be installed first.
npx playwright install --with-deps
npm run testPerformance
The performance of the pure layout calculations (pure JS, without any DOM manipulation) can be evaluated with the included benchmark.
npm run benchThe layout computation for 10'000 images takes around 20ms on average (p99 < 50ms) on my laptop (AMD Ryzen 7 7840U).
Contributing
You are welcome to contribute to this project by opening a Merge Request on Gitlab.
Do note that this project is written in TypeScript with full type support.
As such, every variable should be typed properly and wildcard types like any should be avoided.
Additionally, this project aims to be fully zero-dependency, so no runtime dependencies will be allowed.
For development, a local server can be started for testing and debugging purposes. Its source can be found in demo and adjusted to test out new features.
npm run devThere is also a documentation site including an interactive playground of the component. A development server hosting this site can be started as well.
npm run docs:devLicense
Copyright (c) 2026-present, Tobias Gröger
