# TopMenuBuilder
> Builder for configuring top-level inventory menus with titles, rows, fills, and actions.
`gg.lode.bookshelfapi.api.menu.build.TopMenuBuilder`
---
## Signature
```java
public class TopMenuBuilder extends MenuBuilder
```
---
## Methods
| Method | Return Type | Description |
|--------|-------------|-------------|
| `setTitle(String title)` | `TopMenuBuilder` | Sets the menu title as a string. |
| `setTitle(Component title)` | `TopMenuBuilder` | Sets the menu title as an Adventure Component. |
| `setRows(int rows)` | `TopMenuBuilder` | Sets the number of rows (1-6). |
| `fill(ItemStack item)` | `TopMenuBuilder` | Fills all empty slots with the given item. |
| `outline(ItemStack item)` | `TopMenuBuilder` | Places the item along the outer border. |
| `buildRow(int index, Consumer<RowBuilder> consumer)` | `TopMenuBuilder` | Builds a row at the given index using a [[RowBuilder]]. |
| `editRow(int index, Consumer<RowBuilder> consumer)` | `TopMenuBuilder` | Edits an existing row at the given index. |
| `insertInRow(int row, int slot, ItemStack item)` | `TopMenuBuilder` | Inserts an item at a specific row and slot. |
| `insertInRow(int row, int slot, ItemStack item, Consumer<InventoryClickEvent> event)` | `TopMenuBuilder` | Inserts an item with a click handler at a specific row and slot. |
| `addCloseAction(Consumer<InventoryCloseEvent> action)` | `TopMenuBuilder` | Adds an action triggered when the menu is closed. |
| `addOpenAction(Runnable action)` | `TopMenuBuilder` | Adds an action triggered when the menu is opened. |
| `addClickAction(Consumer<InventoryClickEvent> action)` | `TopMenuBuilder` | Adds a global click action for the menu. |
| `getTitle()` | `String` | Returns the current title. |
| `getRows()` | `int` | Returns the number of rows. |
### Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| `title` | `String` or `Component` | The menu title. |
| `rows` | `int` | Number of rows, between 1 and 6. |
| `item` | `ItemStack` | The item to place. |
| `index` / `row` | `int` | The row index (0-based). |
| `slot` | `int` | The slot index within the row (0-8). |
| `consumer` | `Consumer<RowBuilder>` | Consumer for building/editing a row. |
| `event` | `Consumer<InventoryClickEvent>` | Click event handler. |
| `action` | `Consumer<InventoryCloseEvent>` | Close event handler. |
---
## Usage
```java
@Override
protected @NotNull TopMenuBuilder getTopMenuBuilder(TopMenuBuilder builder) {
return builder
.setTitle("Shop Menu")
.setRows(4)
.fill(new ItemStack(Material.BLACK_STAINED_GLASS_PANE))
.outline(new ItemStack(Material.WHITE_STAINED_GLASS_PANE))
.set(1, 4, new ItemStack(Material.EMERALD), event -> {
// handle click
})
.addCloseAction(event -> {
// handle close
})
.addOpenAction(() -> {
// handle open
});
}
```
---
## Related Pages
- [[Menu]]
- [[MenuBuilder]]
- [[RowBuilder]]