web
Chromatic Gallery
A React component that organises photo galleries by dominant colour
Year
2026
Technologies
React, TypeScript, CSS, npm, gallery, component, Canvas API, Data Visualisation
Chromatic Gallery is a React component I developed to transform standard image collections into visually cohesive works of art. Instead of a chronological jumble, it intelligently organises photos by their dominant colour, creating a beautiful, flowing visual narrative.

The challenge
Most digital photo galleries display images in the order they were uploaded or taken. This chronological sorting often lacks any narrative or aesthetic purpose, resulting in a wall of disconnected thumbnails that can look chaotic and unappealing. My goal was to create a gallery that presented images as a unified collection, where the arrangement itself adds to the viewing experience.
Approach
I decided to build this as a self-contained, reusable React component published on npm, using TypeScript for robust type safety and developer experience. The core of the project relies on client-side image analysis. For each image, I draw it onto a hidden <canvas> element. From there, I access the raw pixel data to analyse its colour composition.
I implemented a quantisation algorithm to group similar colours and identify the most dominant one. This dominant colour is then converted from RGB to its HSL (Hue, Saturation, Lightness) equivalent. The hue value, a number from 0 to 360, provides the perfect basis for sorting the images around the colour wheel. This creates a seamless transition from warm to cool tones across the page.
Performance was a key consideration. The gallery uses the IntersectionObserver API for lazy loading, ensuring only visible images are processed and rendered. I also built in support for responsive images via srcset attributes to serve appropriately sized assets. To enhance the user experience, I added multiple layout modes like grid and columns, and an interactive colour wheel for filtering, all managed within React state.
Key features
- Automatic chromatic sorting based on dominant image colour.
- Interactive colour wheel for filtering images by specific hues.
- Multiple layout modes including responsive grid, masonry columns, and a timeline view.
- Client-side duplicate detection to identify and flag identical images.
- Optimised for performance with lazy loading and support for
srcset. - Packaged as a reusable React component for easy integration into any project.
What I learned
- Manipulating image data on the client side using the Canvas API was a fascinating challenge. It taught me a great deal about pixel analysis and the trade-offs between processing speed and accuracy.
- Implementing colour theory in code, specifically converting RGB values to HSL and using the hue for circular sorting, deepened my understanding of practical data visualisation.
- Developing, testing, and publishing a package to the npm registry provided valuable experience in creating maintainable and distributable front-end components.



