CraftUI

Inventory Screen

A backpack, a hotbar and the character, with the chosen item's details and Use, Drop and Move buttons.

Inventory

Backpack

Oak Planks, 64
Empty slot
Stone, 48
Empty slot
Sea Gem, 3
Empty slot
Empty slot
Apple, 5
Empty slot
Empty slot
Glow Potion
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot

Hotbar

Iron Sword, 90% durability
Iron Pickaxe, 42% durability
Torch, 24
Bread, 12
Empty slot
Empty slot
Empty slot
Empty slot
Empty slot

Details

Iron Sword, 90% durability

Iron Sword

Sharp, and nearly new.

Durability
x
Open on a page of its own

Installation

npx shadcn@latest add @runqora/craft-inventory-screen

Usage

import { InventoryScreen } from "@/components/craft/blocks/inventory-screen";

<InventoryScreen
  defaultContents={{ hotbar, inventory }}
  onContentsChange={save}
  onDrop={(item) => drop(item.id)}
  onUse={(item) => use(item.id)}
/>;

Props

InventoryScreen

Prop

Type

Accessibility

  • The backpack is a grid and the hotbar a list, both named, with the keyboard support of Inventory Grid and Hotbar.
  • The details say the chosen item's name, description and durability in words.
  • Move to hotbar and Move to backpack let keyboard players move items between the two, which dragging alone wouldn't.

Customization

The screen keeps the slots once it starts, and reports every change through onContentsChange, so you can save them. Items are the same objects as in Item Slot. Every screen fills its frame, so give it a height, such as h-dvh for a whole page.

Dependencies

  • craft-button, craft-hotbar, craft-inventory-grid, craft-item-slot, craft-progress and craft-screen
  • shadcn's utils, and craft-theme

Source