import { GridList, GridListItem } from "@senvenli/react/collection";
import { Avatar, Badge } from "@senvenli/react/display";
export default function Example() {
return (
<GridList aria-label="Customers">
<GridListItem id="sofia" leading={<Avatar name="Sofia Marin" src="/avatars/05.webp" />} title="Sofia Marin" description="42 orders · Boston" trailing={<Badge tone="success">Active</Badge>} />
<GridListItem id="claire" leading={<Avatar name="Claire Dubois" src="/avatars/07.webp" />} title="Claire Dubois" description="18 orders · Chicago" trailing={<Badge tone="success">Active</Badge>} />
<GridListItem id="jamal" leading={<Avatar name="Jamal Carter" src="/avatars/08.webp" />} title="Jamal Carter" description="64 orders · Denver" trailing={<Badge tone="warning">Payment pending</Badge>} />
<GridListItem id="lena" leading={<Avatar name="Lena Fischer" src="/avatars/02.webp" />} title="Lena Fischer" description="No orders yet · Portland" trailing={<Badge>Invited</Badge>} />
</GridList>
);
}import {
GridList,
GridListItem,
GridListSection,
} from "@senvenli/react/collection";Examples
Rows in sections
Rows from data, grouped under small headers.import { GridList } from "@senvenli/react/collection";
import { Icon, Badge } from "@senvenli/react/display";
type Delivery = { id: string; customer: string; detail: string; isDelivered?: boolean };
const DELIVERIES: { title: string; items: Delivery[] }[] = [
{
title: "Today",
items: [
{ id: "1042", customer: "Ada Lovelace", detail: "Order SO-1042 · 9:00 AM · Boston", isDelivered: true },
{ id: "1043", customer: "Grace Hopper", detail: "Order SO-1043 · 11:30 AM · Cambridge" },
{ id: "1044", customer: "Alan Turing", detail: "Order SO-1044 · 2:00 PM · Somerville" },
],
},
{
title: "Tomorrow",
items: [
{ id: "1045", customer: "Katherine Johnson", detail: "Order SO-1045 · 10:00 AM · Boston" },
{ id: "1046", customer: "Margaret Hamilton", detail: "Order SO-1046 · 3:30 PM · Quincy" },
],
},
];
export default function Example() {
return (
<GridList
aria-label="Deliveries"
sections={DELIVERIES}
renderItem={(delivery) => ({
id: delivery.id,
leading: <Icon name="package" color="subtle" />,
title: delivery.customer,
description: delivery.detail,
trailing: delivery.isDelivered ? <Badge tone="success">Delivered</Badge> : <Badge tone="information">Scheduled</Badge>,
})}
/>
);
}Picking a set
A checkbox per row, for acting on several at once.import { useState } from "react";
import { GridList, type GridListStackProps } from "@senvenli/react/collection";
import { Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
const INVOICES = [
{ id: "inv-301", customer: "Ada Lovelace", detail: "$248.50 · due March 25" },
{ id: "inv-302", customer: "Grace Hopper", detail: "$96.00 · due March 27" },
{ id: "inv-303", customer: "Alan Turing", detail: "$1,290.00 · due April 2" },
];
type Keys = NonNullable<GridListStackProps["selectedKeys"]>;
export default function Example() {
const [selected, setSelected] = useState<Keys>(new Set(["inv-301"]));
const count = selected === "all" ? INVOICES.length : [...selected].length;
return (
<Stack space="space-150">
<GridList
aria-label="Unpaid invoices"
items={INVOICES}
selectionMode="multiple"
selectedKeys={selected}
onSelectionChange={setSelected}
renderItem={(invoice) => ({ id: invoice.id, title: invoice.customer, description: invoice.detail })}
/>
<Text size="body-small" tone="subtle">{count} selected for a reminder</Text>
</Stack>
);
}One open row
`replace` selection with no checkboxes, for a list beside the record it opens.import { GridList, GridListItem } from "@senvenli/react/collection";
import { Avatar } from "@senvenli/react/display";
export default function Example() {
// The arrow keys move the selection with the focus, as in an inbox.
return (
<GridList aria-label="Conversations" selectionMode="single" selectionBehavior="replace" defaultSelectedKeys={["ada"]}>
<GridListItem id="sofia" leading={<Avatar name="Sofia Marin" src="/avatars/05.webp" size="small" />} title="Sofia Marin" description="Where is my order?" />
<GridListItem id="claire" leading={<Avatar name="Claire Dubois" src="/avatars/07.webp" size="small" />} title="Claire Dubois" description="Thanks, that fixed it." />
<GridListItem id="jamal" leading={<Avatar name="Jamal Carter" src="/avatars/08.webp" size="small" />} title="Jamal Carter" description="Can I change the delivery address?" />
</GridList>
);
}Tiles: product photos
`layout="grid"`: tiles people know by their picture, picked as a set.import { GridList } from "@senvenli/react/collection";
// A stand-in picture as an inline SVG data URI, so the example loads nothing from the network.
const picture = (shape: string) =>
`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120"><rect width="160" height="120" fill="gray" fill-opacity=".2"/>${shape}</svg>`)}`;
const PHOTOS = [
{ id: "front", title: "Front view", size: "1.9 MB", src: picture('<rect x="50" y="30" width="60" height="60" rx="6" fill="gray"/>') },
{ id: "side", title: "Side view", size: "2.3 MB", src: picture('<rect x="65" y="25" width="30" height="70" rx="6" fill="gray"/>') },
{ id: "top", title: "From above", size: "1.4 MB", src: picture('<circle cx="80" cy="60" r="32" fill="gray"/>') },
{ id: "detail", title: "Detail", size: "3.1 MB", src: picture('<path d="M40 90 80 30l40 60z" fill="gray"/>') },
];
export default function Example() {
return (
<GridList layout="grid"
aria-label="Product photos"
items={PHOTOS}
selectionMode="multiple"
defaultSelectedKeys={["front"]}
// The title names the tile, so the image itself needs no alt text.
renderItem={(photo) => ({ title: photo.title, meta: photo.size, media: <img src={photo.src} alt="" /> })}
/>
);
}Reordering
Drag a tile or use its handle from the keyboard; the tile's own buttons do the same on touch.import { useState } from "react";
import { GridList, type GridListGridProps } from "@senvenli/react/collection";
const picture = (shape: string) =>
`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120"><rect width="160" height="120" fill="gray" fill-opacity=".2"/>${shape}</svg>`)}`;
type Photo = { id: string; title: string; src: string };
const PHOTOS: Photo[] = [
{ id: "front", title: "Front view", src: picture('<rect x="50" y="30" width="60" height="60" rx="6" fill="gray"/>') },
{ id: "side", title: "Side view", src: picture('<rect x="65" y="25" width="30" height="70" rx="6" fill="gray"/>') },
{ id: "top", title: "From above", src: picture('<circle cx="80" cy="60" r="32" fill="gray"/>') },
{ id: "detail", title: "Detail", src: picture('<path d="M40 90 80 30l40 60z" fill="gray"/>') },
];
type Reorder = NonNullable<GridListGridProps<Photo>["dragAndDrop"]>["onReorder"];
export default function Example() {
const [photos, setPhotos] = useState(PHOTOS);
// Takes the moved tiles out, then puts them back before or after the target.
const reorder: Reorder = (keys, target) =>
setPhotos((current) => {
const moved = current.filter((photo) => keys.has(photo.id));
const rest = current.filter((photo) => !keys.has(photo.id));
const at = rest.findIndex((photo) => photo.id === target.key) + (target.position === "after" ? 1 : 0);
return [...rest.slice(0, at), ...moved, ...rest.slice(at)];
});
return (
<GridList layout="grid"
aria-label="Product photos, in display order"
items={photos}
dragAndDrop={{ onReorder: reorder }}
renderItem={(photo) => {
const index = photos.indexOf(photo);
return {
title: photo.title,
meta: index === 0 ? "Cover photo" : `Photo ${index + 1}`,
media: <img src={photo.src} alt="" />,
actions: [
{
id: "earlier",
label: `Move earlier: ${photo.title}`,
icon: "arrow-left",
isDisabled: index === 0,
onPress: () => reorder(new Set([photo.id]), { key: photos[index - 1]!.id, position: "before" }),
},
{
id: "later",
label: `Move later: ${photo.title}`,
icon: "arrow-right",
isDisabled: index === photos.length - 1,
onPress: () => reorder(new Set([photo.id]), { key: photos[index + 1]!.id, position: "after" }),
},
],
};
}}
/>
);
}Tiles that open
An icon as the media, and a press or Enter that opens the tile.import { useState } from "react";
import { GridList } from "@senvenli/react/collection";
import { Icon, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
const DOCUMENTS = [
{ id: "invoice", title: "Invoice 2026-0318", meta: "PDF · 84 KB", icon: "file-text" },
{ id: "report", title: "Q1 sales report", meta: "Spreadsheet · 1.2 MB", icon: "file-spreadsheet" },
{ id: "contract", title: "Supplier contract", meta: "PDF · 310 KB", icon: "file-signature" },
] as const;
export default function Example() {
const [opened, setOpened] = useState<string | null>(null);
return (
<Stack space="space-150">
<GridList layout="grid"
aria-label="Documents"
items={DOCUMENTS}
onAction={(key) => setOpened(DOCUMENTS.find((document) => document.id === key)?.title ?? null)}
renderItem={(document) => ({ title: document.title, meta: document.meta, media: <Icon name={document.icon} size="large" /> })}
/>
<Text size="body-small" tone="subtle">{opened ? `Opened: ${opened}` : "Press a tile, or focus it and press Enter."}</Text>
</Stack>
);
}Guidelines
When to use it
- Records read as one line each, and tables on narrow screens (
layout="stack"). - Items people recognize by an image: photos, documents, cards (
layout="grid").
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| Arrow keys | Move between rows, or between tiles in two dimensions. |
| Enter | Opens the focused row or tile. |
| Space | Selects the focused item. |
Built in
- Sections are named for screen readers.
- Tile actions are always visible, so they need no hover and work on touch.
- A drag handle gives the keyboard a way to reorder tiles.
You provide
- An aria-label.
- A name for each tile action that names the tile.
API reference
GridList
| Prop | Type | Default | Description |
|---|---|---|---|
aria-labelRequired | string | – | Names the list ("Today's deliveries"). |
children | React.ReactNode | – | GridListItem rows, or ListSections of them; or give |
items | readonly T[] | – | |
sections | readonly GridListSectionData<T>[] | – | Grouped rows under small headers ("Today", "Tomorrow"). |
renderItem | (item: T) => GridListItemProps | (item: T) => GridTileContent | – | One row's content for |
selectionMode | "none" | "single" | "multiple" | – | |
selectionBehavior | "toggle" | "replace" | – | How a press selects. |
selectedKeys | "all" | Iterable<Key> | – | |
defaultSelectedKeys | "all" | Iterable<Key> | – | |
onSelectionChange | (keys: Selection) => void | – | |
onAction | (key: Key) => void | – | Opens the row's record. |
emptyState | React.ReactNode | – | Shown when there are no rows: an |
layout | "stack" | "grid" | – | |
itemKey | (item: T) => Key | – | The item's stable id; |
dragAndDrop | { onReorder: (keys: Set<Key>, target: { key: Key; position: "before" | "after" }) => void } | – | Reordering (photos): drag a tile, or focus its handle and use the keyboard. |
ref | React.Ref<HTMLDivElement> | – | The grid element. Focusing it focuses the tile React Aria keeps as focused (the next one after a removed tile), so it is the |
aria-labelRequiredstringNames the list ("Today's deliveries").
childrenReact.ReactNodeGridListItem rows, or ListSections of them; or give
items(orsections) andrenderItem.itemsreadonly T[]sectionsreadonly GridListSectionData<T>[]Grouped rows under small headers ("Today", "Tomorrow").
renderItem(item: T) => GridListItemProps | (item: T) => GridTileContentOne row's content for
items/sections.selectionMode"none" | "single" | "multiple"selectionBehavior"toggle" | "replace"How a press selects.
toggle(default): each row has a checkbox and a press adds or removes it, for picking a set to act on.replace: no checkboxes; a press selects that row in place of the last, and withsinglethe arrow keys move the selection, for a list that shows one open record beside it (an inbox's conversation). The selected row keeps its marker either way. WithonActionas well, a press runs the action and selection needs the keyboard (React Aria's replace rule), so a replace list usually leavesonActionout.selectedKeys"all" | Iterable<Key>defaultSelectedKeys"all" | Iterable<Key>onSelectionChange(keys: Selection) => voidonAction(key: Key) => voidOpens the row's record.
emptyStateReact.ReactNodeShown when there are no rows: an
EmptyStateor a sentence.layout"stack" | "grid"itemKey(item: T) => KeyThe item's stable id;
item.idby default.dragAndDrop{ onReorder: (keys: Set<Key>, target: { key: Key; position: "before" | "after" }) => void }Reordering (photos): drag a tile, or focus its handle and use the keyboard.
onReordergets the moved keys and the tile they go before or after.refReact.Ref<HTMLDivElement>The grid element. Focusing it focuses the tile React Aria keeps as focused (the next one after a removed tile), so it is the
returnFocusReffor a confirm whose action removes the tile it was opened from.
GridListItem
| Prop | Type | Default | Description |
|---|---|---|---|
idRequired | Key | – | |
leading | React.ReactNode | – | A visual at the start: an Avatar, an icon or a thumbnail. |
titleRequired | string | – | The one primary line ("Ada Lovelace"); also the row's text for typeahead. |
description | React.ReactNode | – | The context the reader scans for: item, time, place ("Order 1042 · 10:00 · Berlin"). |
trailing | React.ReactNode | – | At the end: a Badge for status, then a subtle icon-button menu. |
href | string | – | Makes the row a link to the record. |
idRequiredKeyleadingReact.ReactNodeA visual at the start: an Avatar, an icon or a thumbnail.
titleRequiredstringThe one primary line ("Ada Lovelace"); also the row's text for typeahead.
descriptionReact.ReactNodeThe context the reader scans for: item, time, place ("Order 1042 · 10:00 · Berlin").
trailingReact.ReactNodeAt the end: a Badge for status, then a subtle icon-button menu.
hrefstringMakes the row a link to the record.
GridListSection
| Prop | Type | Default | Description |
|---|---|---|---|
titleRequired | string | – | |
childrenRequired | React.ReactNode | – |
titleRequiredstringchildrenRequiredReact.ReactNode