Parquet
A colour mosaic where each tile's area is its weight. When the palette changes, the tiles re-pack and morph into place.
@patternmode/parquet
Terracotta42%
Forest28%
Navy18%
Blush12%
The same array as a distribution bar and a list. Pick a colour to make it the largest tile.
Reference
States and variants
Read-only and controlled. Pass a new colors array to morph to a new palette.
No labels
defaultLabel and share on hover
showLabelsWider frame
aspectRatio={2}Tighter gap
gap={4}Fewer colours, stable slots
slotCount={4}- #C2703E#2D5A27
Your own tile content
renderTile(tile, meta)
Install and use
The same array can drive a Swatch DistributionBar and a Parquet.
npm i @patternmode/parquetimport { Parquet } from "@patternmode/parquet";
import "@patternmode/parquet/styles.css";
const palette = [
{ color: "#c2703e", value: 0.42, label: "Terracotta" },
{ color: "#2d5a27", value: 0.28, label: "Forest" },
{ color: "#1b2a4a", value: 0.18, label: "Navy" },
{ color: "#e8b4b8", value: 0.12, label: "Blush" },
];
<Parquet colors={palette} showLabels />Core API
Parquet
A controlled, proportional color mosaic. Each tile's area encodes its weight.
colors- ParquetTile[]Weighted colors to pack. Each tile extends WeightedColorSegment ({ color, value, label? }). The mosaic re-tiles and morphs whenever this changes.
aspectRatio- number4 / 3Aspect ratio (width / height) of the mosaic.
gap- number10Gap between tiles, in the mosaic's internal layout units.
slotCount- numbercolors.lengthFixed number of tile slots. Render a stable count so morphs between palettes of different lengths stay smooth; extra slots collapse to nothing.
showLabels- booleanfalseShow the built-in label (color name + derived percentage) on hover, with a contrast-aware foreground.
renderTile- (tile, meta) => ReactNodeReplace the built-in label with custom content. Receives the tile and its derived { percent, isLight, slot }.
disableMotion- booleanfalseDisable enter and morph animation. prefers-reduced-motion also disables it.
Accessibility
The mosaic is a picture. Put the same values in text beside it.
- Text alternative
- The mosaic carries no name of its own, and hover labels can't be reached by keyboard. List the values nearby.
- Label contrast
- Built-in labels pick light or dark text from each tile's perceptual lightness.
- Reduced motion
- The morph is switched off. disableMotion does the same everywhere.
Package
- Package
- @patternmode/parquet
- Version
- 0.1.10
- Needs
- react, react-dom
- Licence
- MIT