Skip to content

Interface: TileLayoutProps ​

Extends ​

  • Omit<HTMLAttributes<HTMLDivElement>, "children">

Properties ​

animate? ​

ts
optional animate?: 
  | boolean
  | {
  duration?: number;
  easing?: string;
};

Animate changes: when the layout changes (a resize, another tiling, a new gap) or the children do, tiles glide and morph into their new places and shapes, a child keeping its tile as it moves; new tiles fade in and removed ones fade out. Pure CSS transitions, skipped when the user prefers reduced motion. true for 400 ms, or { duration, easing }.


aspects? ​

ts
optional aspects?: readonly number[];

Width / height of each child, in order. When given, each child goes in a tile of similar shape, so object-fit: cover crops as little as possible (landscape photos in wide tiles, portraits in tall ones); see matchSlots. Featured tiles still take the first children. Missing entries count as square. Ignored with renderCell.


backdrop? ​

ts
optional backdrop?: ReactNode;

One picture across all the tiles: rendered in every tile, sized and positioned to the whole layout, so each tile shows its own piece. Use an element that fills its box, e.g. <img src=… style={coverStyle} />. It sits behind the tile's content, and empty tiles show it instead of fill. (Each tile gets its own copy, so a video would play out of sync; images are loaded once.)


background? ​

ts
optional background?: string;

Color painted across the whole region, visible through the gaps.


cellClassName? ​

ts
optional cellClassName?: PerCell<string>;

Class name for each tile wrapper (fixed or per cell).


cellLabel? ​

ts
optional cellLabel?: PerCell<string | undefined>;

Accessible name for each tile (its aria-label), e.g. a photo's description.


cellStyle? ​

ts
optional cellStyle?: PerCell<CSSProperties>;

Extra style for each tile wrapper (fixed or per cell), e.g. a background color.


children? ​

ts
optional children?: ReactNode;

Any React content. Each top-level child fills one tile, in reading order (top-to-bottom, left-to-right), and is clipped to the tile's shape. Extra children beyond the number of tiles are not rendered.


choose? ​

ts
optional choose?: "placement" | "shape";

With aspects: "shape" also picks which tiles hold children by their shape, ignoring placement.


contentCells? ​

ts
optional contentCells?: ContentCells;

Which tiles may hold children: "all" (default), "whole" (only tiles not cut by the region outline), or a test per cell. The others are left empty.


fallback? ​

ts
optional fallback?: PerCell<ReactNode>;

Content for empty tiles.


fill? ​

ts
optional fill?: FillSource;

Color of empty tiles: a color, a palette (neighboring tiles get different entries), or a function per cell. Defaults to neutralPalette; use "transparent" for none.


fit? ​

ts
optional fit?: FitProp;

Size the tiles to the children: scales the pattern so there are about as many tiles (counted by contentCells) as children. true/"atLeast" makes sure every child gets a tile; "nearest" gets as close as possible. Ignored with layout or renderCell.


focalPoints? ​

ts
optional focalPoints?: readonly (Focus | undefined)[];

Focal point of each child (fractions of its width and height; see estimateFocus): what a photo keeps in view as its tile crops it. Each tile sets --andamento-object-position, which coverStyle uses as object-position; exact when the photo's shape is known (aspects, or the focus's aspect).


focusRing? ​

ts
optional focusRing?: string | false;

Color of the focus outline drawn inside the focused tile's shape (a CSS outline would be clipped away), with a white inner line so it shows on any content. false for none, if you style [data-cell-id]:focus-visible yourself. Defaults to "#1a56db".


layout? ​

ts
optional layout?: Layout;

ts
optional navigable?: boolean;

Keyboard navigation: tiles with content become focusable as one tab stop (roving tabindex). Arrow keys move to the nearest tile in that direction, whatever the tiling; Home and End go to the first and last. The focused tile shows focusRing.


onCellActivate? ​

ts
optional onCellActivate?: (cell, state) => void;

Called when a tile with content is activated: clicked, or Enter or Space while it has focus (with navigable).

Parameters ​

ParameterType
cellCell
stateCellState

Returns ​

void


options? ​

ts
optional options?: LayoutOptions;

Layout options; or pass a precomputed layout instead.


placement? ​

ts
optional placement?: ContentPlacement;

Where children go when there are fewer than tiles: "reading" (default; the first tiles in reading order), "center" (the middle of the region) or "spread" (evenly over it). Children always run in reading order across the tiles chosen.


relief? ​

ts
optional relief?: boolean | ReliefOptions;

Raised tiles: a bevel round each tile, lit from one side and drawn over its content, and optionally a soft shadow each tile casts into the grout (set shadow). true for the defaults. With gap as the grout width and background as its color or texture, it looks like a tiled surface. See ReliefOptions.


renderCell? ​

ts
optional renderCell?: (cell, state) => ReactNode;

Alternative to children: compute each tile's content from its cell. Takes precedence. slot numbers the cells allowed by contentCells in reading order (-1 for the rest).

Parameters ​

ParameterType
cellCell
state{ slot: number; }
state.slotnumber

Returns ​

ReactNode


safeArea? ​

ts
optional safeArea?: SafeAreaProp;

Keep content out of the tiles' clipped corners: each tile's content goes in a box at the tile's safe area (see safeArea), the largest rectangle that fits inside its shape, instead of filling the tile's bounding box. Useful for text in triangles or hexagons. With aspects, each child's box has the child's shape, so it shows whole and uncropped. The box has data-safe-area; style its contents to fill it. Tiles show fill around their content. For tiles an edges: "window" layout cuts, true or "tile" fits the whole tile (content near the edge is partly hidden, like the tile) and "visible" the part that shows.


virtualize? ​

ts
optional virtualize?: 
  | boolean
  | {
  overscan?: number;
};

Mount only the tiles in view (plus overscan pixels round it, default 300), for layouts with thousands of tiles. Tiles mount and unmount as the page or any scrolling container scrolls, or the layout resizes. Keyboard navigation still reaches every tile (the focused one stays mounted and is scrolled to), and list items carry aria-setsize and aria-posinset. With renderCell, every cell contentCells allows counts as having content. On the server no tiles are rendered.


weights? ​

ts
optional weights?: readonly number[];

How many tiles each child spans (1 for an ordinary child; rounded): heavier childs get a featured tile of that many merged tiles, where they fall in reading order (see weightedLayout). With fit, the tiles are sized to fit everything. Needs options.

Hat tiling and isohedral tilings after Craig S. Kaplan's hatviz and Tactile (BSD 3-Clause).