Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Tone Filter Gallery Block for React

Five greyscale swatches (Paper to Ink) with counts, a Sort by contrast button and twelve framed pictures whose tone and contrast are read from their own drawings.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A tone filter for React with Base UI, for Tonebank, a reference library for illustrators. A centred header sits over a band of five swatches (Paper, Mist, Stone, Slate and Ink) in a multi-select ToggleGroup, each with the number of pictures in that tone, and a "Sort by contrast" button. The pictures are greyscale on purpose, so the filter is about value, not hue: each picture's tone and contrast are read from its own drawing (the ground and every shape painted over it, on a coarse grid), never typed. Twelve framed pictures sit apart, each with its tone and contrast in its caption. Choosing swatches keeps only those tones, sorting puts the highest contrast first, and a polite line says "Showing 5 of 12 pictures". An unseen copy of all twelve holds the block's height. On a phone the swatches are a row of five and the pictures two across. It's built from ToggleGroup, Button and Guides. The library is made up for the example.

FAQ

Where do the tones come from?

From the drawing. A module function paints each picture's ground and then every shape over it on a 24 by 16 grid, each shape covering the box that holds its path, and a cell's value is how much ink is in it. The picture's tone is the mean of the cells and its contrast is how far they spread. It is an estimate (a box is bigger than the shape in it) but it is computed from the picture's own data, and the five tones are thresholds on it. With real photographs, replace readingOf with a luminance read from the image.

How does

It is a pressed button: on, the shown pictures are ordered by contrast, highest first, and the status line says so; off, they return to reading order. It combines with the swatches. Sorting changes only the order, and the block's height never changes.

Why doesn't the page jump when the pictures change?

An unseen copy of all twelve pictures (hidden from assistive technology and from the keyboard) sits in the same grid cell as the live set, so the block is always as tall as the full gallery and the shown pictures stay at the top. Nothing below the block moves.

How do the swatches combine?

They are a multi-select group: none chosen shows every tone, and each swatch you add shows that tone as well. Each swatch is a solid mix of the pictures' own ink over their paper, never a hue (so Ink is the darkest in a dark theme too), and the chosen one is ringed in the text colour. Counts are derived from the pictures, so they always add up to the total.

How do I use my own photographs?

Each picture is typed data with a description (its alt text), a scene and a ratio. Add your image's address to it, then replace the Scene in its tile with <img alt="" className="size-full object-cover" src={…} />: the caption already names the picture, and the role="img" wrapper's label can move to the alt. The comment above Scene says where. Tiles crop to a fixed shape, so keep object-cover.

Does it follow my theme?

Yes. Every colour is mixed from your foreground, background and muted tokens, so the pictures print dark on pale grey in a light theme and turn low-key in a dark one. The chosen state of every control is the text colour on the page colour; the primary colour stays on the page's one action. The block ends on its last row with no closing line, so the next section's top rule closes it.

  • Pro

    Twelve of the theme's own colour tokens as swatches on shared hairlines, each with its name and its painted value in the format you choose, and a Copy button that copies exactly that text.

  • Pro

    Tagged Gallery

    Filter, sort and tabs

    Twenty-four drawn pictures filtered by a cloud of ten tags with live counts that combine with AND, removable chips, a Clear button and an empty state.

  • Pro

    Filterable Gallery

    Filter, sort and tabs

    Twelve drawn pictures on shared hairlines with a band of chips, each with a count, that keeps only one kind of work and says how many are showing.

  • Pro

    Pattern Kit Gallery

    Design assets

    Twelve tileable CSS surfaces in cells on shared hairlines, with a Scale slider and a Contrast slider that repaint every cell live, and a Copy CSS button that copies the real rule for the pattern you choose.

  • Pro

    Mood Board Gallery

    Walls and tables

    A pinboard of twelve pieces of five kinds (pictures, paint chips, materials, words and type) pinned a degree off square, with a lens that dims the other kinds without moving anything.

  • Pro

    A quiet grid of twenty-four drawn concrete-architecture plates, eight to a page on shared hairlines, with a title and year that appear on hover and focus and the catalog pagination in a band that ends the block.