Grid View

Grid-based file and folder display with default item rendering.

Overview

Files.Grid lays out Files.Item children in an iCloud-style justified file grid. Cubitt owns the measured row layout, final-row spacer cells, item visuals, selection interaction, focus treatment, upload/error display, and folder/file icon rendering. Consumers own the item array, filtering, sorting, folder-first ordering, folder navigation, upload state, and actions.

Usage

import {
  Files,
  type FilesItem,
} from "@tilt-legal/cubitt-components/files";

function FileGrid({
  items,
  selectedIds,
  setSelectedIds,
}: {
  items: FilesItem[];
  selectedIds: string[];
  setSelectedIds: (ids: string[]) => void;
}) {
  return (
    <Files
      selectedIds={selectedIds}
      onSelectedIdsChange={setSelectedIds}
      selectionMode="multiple"
    >
      <Files.Grid>
        {items.map((item) => (
          <Files.Item
            item={item}
            key={item.id}
            onOpen={(openedItem) => {
              if (openedItem.kind === "folder") {
                navigateToFolder(openedItem.id);
              }
            }}
          />
        ))}
      </Files.Grid>
    </Files>
  );
}

Grid Item

Files.Item renders one file or folder inside the measured grid. Its status value controls only file lifecycle display:

StatusDescription
omittedNormal folder, virtual file, or MIME icon display.
loadingSkeleton placeholder for an item whose data is not ready yet.
uploadingCircular progress treatment. Use status.progress for value.
errorFailed upload treatment.

Selection, active highlight, inline rename, drag, drop-target, disabled, hover, and focus are interaction states owned by Files and item props, not FilesItem.status values.

Props

Files.Grid

PropTypeDefaultDescription
childrenReactNode-Files.Item children.
classNamestring-Extends the grid root.

Also accepts standard table props. Files.Grid has no items, sorting, density, or layout prop.

Files.Item

PropTypeDefaultDescription
itemFilesItem-File or folder display data.
onOpen(item, event) => void-Called on double click, or Enter when inline rename is unavailable.
disabledbooleanfalseDisables the item in addition to root and item data disabled state.
classNamestring-Extends the item root.

Selection is controlled by the root Files props: selectedIds, onSelectedIdsChange, selectionMode, selectionBehavior, and optional canSelect.

On this page