Item Info

The details of an item: rarity, type, description, stats with +/- against the equipped one, value and action buttons. As a card, a compact tooltip or a panel.

View as Markdown

compareTo shows green and red deltas per stat. Actions carry their own handler and keyboard hint.

Lotus hat
RareHeadLv 8
Woven by the best hands in the village.
Heat resist
+7+3
Charm
+3+2

Compared with your Straw hat.

180 coins
Moon gem
LegendaryGem
Glows softly on festival nights.
1200 coins

Installation

npx shadcn@latest add @cozy/item-info

Usage

import { ItemInfo, ItemTooltip } from "@/components/ui/item-info"

<ItemInfo item={item} actions={[{ id: "use", label: "Use", onSelect: use }]} />

Examples

Tooltip

Wrap any trigger, usually an ItemSlot, in ItemTooltip. It opens on hover and on keyboard focus.

API

Everything else is passed through to the underlying element or Radix primitive.

PropTypeDefaultDescription
itemGameItem–The item to show.
compareToGameItem | null–Shows a delta for each stat with a numeric amount; better: "lower" flips the colour.
actions{ id, label, onSelect?, variant?, disabled?, shortcut? }[]–Buttons in the footer.
variant"card" | "compact" | "panel""card"Card is 340px wide, compact suits tooltips, panel fills its container.
formatValue(value, item) => ReactNode"{value} coins"How the value prints; return null to hide it.
renderStats / childrenfn / ReactNode–Replace the stats list, or add lore, set bonuses or requirements under it.