Skip to main content

SlotGrid

A grid of cells over a JSON UI collection the screen does not own, inside a container screen: the player's own inventory, another container's items, or any collection the engine exposes.

Import​

import { SlotGrid } from '@bedrock-core/ui';

Usage​

{/* The player's inventory, read-only. */}
<SlotGrid collection={'inventory_items'} columns={9} rows={3} interactive={false} />

Where a Slot is one cell, a SlotGrid is a whole collection at once. It reads the collection straight — it is not part of the screen's own container, so it takes no slot of it and the runtime never polls it. An interactive grid is driven by the engine's own take and place on that collection; a display-only one is inert.

Its size is fixed by the cell: columns × rows cells of 18 texels each. Lay it out like any other node.

Props​

PropTypeDefaultDescription
collection*string—The JSON UI collection every cell reads, e.g. inventory_items, hotbar_items, or a custom one
columns*number—Columns of cells. At least one
rows*number—Rows of cells. At least one
interactivebooleantrueWhether the player can move items through the cells. false makes the grid inert — no take, no place, no drop

Inherits control props. Its size is fixed by the cell; use alignSelf, margins and the surrounding panel to place it.

A container slot's take and place are one combined engine action, so there is no take-only or place-only grid: interactivity is all-or-nothing, and false is the way to make a grid purely a display.

PlayerInventory and Hotbar​

PlayerInventory and Hotbar are thin SlotGrid wrappers:

const PlayerInventory = props => <SlotGrid collection={'inventory_items'} columns={9} rows={3} {...props} />;
const Hotbar = props => <SlotGrid collection={'hotbar_items'} columns={9} rows={1} {...props} />;

Reach for SlotGrid directly when you want a different shape — a read-only mirror, a sub-range, or another entity's collection.

Own slots versus foreign cells​

ReadsAllocated a container slotPolled by the runtimeRoles
Slot (own)the screen's own container_itemsyesyesboth / input / output
Slot collection (foreign)the named collectionnononone — use interactive
SlotGridthe named collectionnononone — use interactive

A grid is never polled by the runtime — the engine's own take and place drive it. What is baked into the JSON UI is inertness: a display-only grid withholds focus, so nothing in it can be taken, placed or dropped.