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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQAumujy5kXaOKurr6zgTP2krHrFVXi2kj8seRYrlvq2GssUjReh5MiVpQbLFQNy9HsmcasqpBNVsXytWTw0ZDjA=

Masonry

import { Masonry } from '@dxos/react-ui-masonry';
Terminal window
npm install @dxos/react-ui-masonry

Masonry packs tiles of different heights into columns. It puts each tile in the shortest column, so the columns have no gaps.

The number of columns follows the width the masonry has. When the items change, the tiles that stay move to their new places, and the masonry measures only the new ones.

Part What it is
Masonry.Root The root, which takes the Tile that draws one item, and the column sizes
Masonry.Content The scroll area for the tiles
Masonry.Viewport The tiles. It takes the items and a getId for each

Masonry.Root takes these props:

Prop Type Effect
Tile ComponentType<{ data }> Draws one item
minColumnWidth number Sets the narrowest a column gets, in rem
maxColumnWidth number Sets the widest a column gets, in rem
maxColumns number Sets the most columns
gap number Sets the space between tiles, in rem

Build each tile from a Card from @dxos/react-ui, so the tiles match the rest of the app.

Example (Laying out a photo gallery)

import {
const Masonry: {
Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
};
Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
Viewport: <Item>(props: MasonryViewportProps<Item> & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
}
Masonry
} from '@dxos/react-ui-masonry';
import * as
import Card
Card
from '@dxos/react-ui/Card';
type
type Photo = {
id: string;
title: string;
color: string;
height: number;
caption?: string;
}
Photo
= {
id: string
id
: string;
title: string
title
: string;
color: string
color
: string;
height: number
height
: number;
caption?: string | undefined
caption
?: string;
};
const
const PHOTOS: Photo[]
PHOTOS
:
type Photo = {
id: string;
title: string;
color: string;
height: number;
caption?: string;
}
Photo
[] = [
{
id: string
id
: '1',
title: string
title
: 'Harbor',
color: string
color
: '#0891b2',
height: number
height
: 80,
caption?: string | undefined
caption
: 'Boats at first light.',
},
{
id: string
id
: '2',
title: string
title
: 'Dunes',
color: string
color
: '#ca8a04',
height: number
height
: 48 },
{
id: string
id
: '3',
title: string
title
: 'Forest',
color: string
color
: '#059669',
height: number
height
: 104,
caption?: string | undefined
caption
: 'A path through the pines, after rain.',
},
{
id: string
id
: '4',
title: string
title
: 'Peaks',
color: string
color
: '#4f46e5',
height: number
height
: 64 },
{
id: string
id
: '5',
title: string
title
: 'Market',
color: string
color
: '#e11d48',
height: number
height
: 88,
caption?: string | undefined
caption
: 'Saturday stalls.',
},
{
id: string
id
: '6',
title: string
title
: 'Canyon',
color: string
color
: '#ea580c',
height: number
height
: 56 },
{
id: string
id
: '7',
title: string
title
: 'Lagoon',
color: string
color
: '#2563eb',
height: number
height
: 72,
caption?: string | undefined
caption
: 'Still water, no wind.',
},
{
id: string
id
: '8',
title: string
title
: 'Meadow',
color: string
color
: '#65a30d',
height: number
height
: 60 },
{
id: string
id
: '9',
title: string
title
: 'Glacier',
color: string
color
: '#0ea5e9',
height: number
height
: 120,
caption?: string | undefined
caption
: 'Blue ice under a gray sky.',
},
{
id: string
id
: '10',
title: string
title
: 'Orchard',
color: string
color
: '#16a34a',
height: number
height
: 52 },
{
id: string
id
: '11',
title: string
title
: 'Lighthouse',
color: string
color
: '#dc2626',
height: number
height
: 96,
caption?: string | undefined
caption
: 'The lamp turns at dusk.',
},
{
id: string
id
: '12',
title: string
title
: 'Desert',
color: string
color
: '#d97706',
height: number
height
: 68 },
{
id: string
id
: '13',
title: string
title
: 'Bridge',
color: string
color
: '#7c3aed',
height: number
height
: 84,
caption?: string | undefined
caption
: 'Fog over the river.',
},
{
id: string
id
: '14',
title: string
title
: 'Reef',
color: string
color
: '#0d9488',
height: number
height
: 44 },
{
id: string
id
: '15',
title: string
title
: 'Vineyard',
color: string
color
: '#9333ea',
height: number
height
: 112,
caption?: string | undefined
caption
: 'Rows down to the lake.',
},
{
id: string
id
: '16',
title: string
title
: 'Tundra',
color: string
color
: '#64748b',
height: number
height
: 58 },
];
/** A tile draws one item; the masonry measures each tile and places it in the shortest column. */
const
const PhotoTile: ({ data: photo }: {
data: Photo;
}) => React.JSX.Element

A tile draws one item; the masonry measures each tile and places it in the shortest column.

PhotoTile
= ({
data: Photo
data
:
photo: Photo
photo
}: {
data: Photo
data
:
type Photo = {
id: string;
title: string;
color: string;
height: number;
caption?: string;
}
Photo
}) => (
<
import Card
Card
.
const Root: React.ForwardRefExoticComponent<Omit<Omit<Card.RootProps, "classNames">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
export Root

A card one level above its host (level='+1'), whose Header, Body and Footer share one content edge. With grid it is a rail Container (the child div wins the asChild merge, so the part keeps the card scope); without, a plain column that creates no grid. With onClick the card is a button (Enter and Space activate it); nested actions and menus stop their clicks reaching it.

Root
>
<
JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
HTMLAttributes<T>.style?: React.CSSProperties | undefined
style
={{
StandardLonghandProperties<string | number, string & {}>.height?: Property.Height<string | number> | undefined

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Syntax: auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>

Initial value: auto

| Chrome | Firefox | Safari | Edge | IE | | :----: | :-----: | :----: | :----: | :---: | | 1 | 1 | 1 | 12 | 4 |

height
:
photo: Photo
photo
.
height: number
height
,
StandardShorthandProperties<string | number, string & {}>.background?: Property.Background<string | number> | undefined

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Syntax: <bg-layer>#? , <final-bg-layer>

| Chrome | Firefox | Safari | Edge | IE | | :----: | :-----: | :----: | :----: | :---: | | 1 | 1 | 1 | 12 | 4 |

background
:
photo: Photo
photo
.
color: string
color
}} />
<
import Card
Card
.
const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>
export Header

A block row across the card's rails holding the Title: a Block or icon-only Button before the Title fills the start rail, and the last one after it the end rail, so the Title starts at the content edge.

Header
>
<
import Card
Card
.
const Title: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<TypographyProps, "lines" | "tone" | "truncate"> & React.RefAttributes<HTMLHeadingElement>>
export Title

An h3 on Typography, so it clamps (lines), truncates and takes a tone like any text.

Title
>{
photo: Photo
photo
.
title: string
title
}</
import Card
Card
.
const Title: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<TypographyProps, "lines" | "tone" | "truncate"> & React.RefAttributes<HTMLHeadingElement>>
export Title

An h3 on Typography, so it clamps (lines), truncates and takes a tone like any text.

Title
>
</
import Card
Card
.
const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>
export Header

A block row across the card's rails holding the Title: a Block or icon-only Button before the Title fills the start rail, and the last one after it the end rail, so the Title starts at the content edge.

Header
>
{
photo: Photo
photo
.
caption?: string | undefined
caption
&& (
<
import Card
Card
.
const Row: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
icon?: string;
leading?: React.ReactNode;
trailing?: React.ReactNode;
end?: React.ReactNode;
current?: boolean;
span?: "full" | "end";
align?: "start";
} & React.RefAttributes<HTMLDivElement>>
export Row

A block-tall row of icon, text and trailing content, laid out inline; in a grid card it is a subgrid, so the icon lands in the card's start rail, the text in its content track and the trailing content in its end rail. With onClick the row is a button (Enter and Space activate it), as the current Card.Action row was.

Row
classNames?: ClassNameValue
classNames
='pb-2'>
<
import Card
Card
.
const Text: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
truncate?: boolean;
lines?: number;
variant?: "default" | "muted";
} & React.RefAttributes<HTMLParagraphElement>>
export Text

Card text on Typography, with the current Card.Text variants.

Text
variant?: "default" | "muted" | undefined

description reads as secondary text.

variant
='muted'
lines?: number | undefined

At most this many lines, the last ending in an ellipsis.

lines
={2}>
{
photo: Photo
photo
.
caption?: string
caption
}
</
import Card
Card
.
const Text: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
truncate?: boolean;
lines?: number;
variant?: "default" | "muted";
} & React.RefAttributes<HTMLParagraphElement>>
export Text

Card text on Typography, with the current Card.Text variants.

Text
>
</
import Card
Card
.
const Row: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
icon?: string;
leading?: React.ReactNode;
trailing?: React.ReactNode;
end?: React.ReactNode;
current?: boolean;
span?: "full" | "end";
align?: "start";
} & React.RefAttributes<HTMLDivElement>>
export Row

A block-tall row of icon, text and trailing content, laid out inline; in a grid card it is a subgrid, so the icon lands in the card's start rail, the text in its content track and the trailing content in its end rail. With onClick the row is a button (Enter and Space activate it), as the current Card.Action row was.

Row
>
)}
</
import Card
Card
.
const Root: React.ForwardRefExoticComponent<Omit<Omit<Card.RootProps, "classNames">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
export Root

A card one level above its host (level='+1'), whose Header, Body and Footer share one content edge. With grid it is a rail Container (the child div wins the asChild merge, so the part keeps the card scope); without, a plain column that creates no grid. With onClick the card is a button (Enter and Space activate it); nested actions and menus stop their clicks reaching it.

Root
>
);
/** Tiles of different heights packed into columns; the number of columns follows the width, at least 9rem each. */
export const
const PhotoGallery: () => React.JSX.Element

Tiles of different heights packed into columns; the number of columns follows the width, at least 9rem each.

PhotoGallery
= () => (
<
const Masonry: {
Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
};
Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
Viewport: <Item>(props: MasonryViewportProps<Item> & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
}
Masonry
.
type Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
}
Root
Tile?: React.ComponentType<{
data: any;
index: number;
selected?: boolean;
}> | undefined

Render component for each masonry item. Receives selected when the grid is selectable.

Tile
={
const PhotoTile: ({ data: photo }: {
data: Photo;
}) => React.JSX.Element

A tile draws one item; the masonry measures each tile and places it in the shortest column.

PhotoTile
}
minColumnWidth?: number | undefined

Minimum column width in rem.

minColumnWidth
={9}>
<
const Masonry: {
Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
};
Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
Viewport: <Item>(props: MasonryViewportProps<Item> & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
}
Masonry
.
type Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element
Content
>
<
const Masonry: {
Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
};
Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
Viewport: <Item>(props: MasonryViewportProps<Item> & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
}
Masonry
.
type Viewport: <Item>(props: MasonryViewportProps<Item> & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element
Viewport
items: readonly Photo[]

Items to render in the masonry grid.

items
={
const PHOTOS: Photo[]
PHOTOS
}
getId?: ((data: Photo) => string) | undefined

Extract a stable key from an item, aligned with react-ui-mosaic's getId.

getId
={(
photo: Photo
photo
) =>
photo: Photo
photo
.
id: string
id
} />
</
const Masonry: {
Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
};
Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
Viewport: <Item>(props: MasonryViewportProps<Item> & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
}
Masonry
.
type Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element
Content
>
</
const Masonry: {
Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
};
Content: (props: MasonryContentProps & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
Viewport: <Item>(props: MasonryViewportProps<Item> & {
ref?: React.Ref<HTMLDivElement | null>;
}) => React.JSX.Element;
}
Masonry
.
type Root: {
({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gap, animate, centered, }: MasonryRootProps): React.JSX.Element;
displayName: string;
}
Root
>
);

PhotoTile draws one photo as a card, and minColumnWidth keeps each column at least 9rem wide. Masonry.Viewport takes the photos as items and reads each one’s id with getId.

The story at the top of this page is a different gallery. It shows portrait cards of people, in columns at least 10rem wide.