Skip to content

Slots

@Composable



fun Slots(
    id: String, 
    width: Int = 1, 
    height: Int = 1, 
    content: @Composable



 () -> Unit = {
        Column {
            repeat(height) {
                Row {
                    repeat(width) {
                        Slot()
                    }
                }
            }
        }
    }
): SlotGroup

Defines a named region of inventory slots within a ComposeContainerScreen.

This composable tracks its absolute on-screen position and populates the enclosing SlotData with the group's location and dimensions so that ComposeContainerMenuBase can register the corresponding vanilla net.minecraft.world.inventory.Slots.

May be declared from more than one place at once - typically a screen and a layer opened over it, which needs the group's slots reachable above its own content. There is only one group per id to place, so the deepest declaration wins it and the others reserve its footprint and draw nothing; see SlotData.slotGroupOwner.

Return

The SlotGroup that will be populated once the layout runs - the owner's, which is not this call site's own when something deeper has taken the group over.

Parameters

  • id: The name that matches the handler(id, storage) call in your menu.

  • width: The number of slot columns in this group. Defaults to 1.

  • height: The number of slot rows in this group. Defaults to 1.

  • content: The composable Slot grid inside this region.