Game UI
Special
Gaming UI components including health bars, inventory, achievements, and damage numbers.
Import
import {
PixelHealthBar,
PixelManaBar,
PixelXPBar,
PixelInventory,
PixelInventorySlot,
PixelAchievement,
PixelDamageNumber
} from "@/components/ui/pixel/pixel-game-ui"Usage
🧙
Wizard
Level 12
HP85/100
MP60/100
XP350/500
Inventory
⚔️
🛡️
💊5
🔮
👑
50
25
100!
Component Source
Copy and paste the following code into your project at /src/components/ui/pixel/pixel-game-ui.tsx
"use client";
import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";
import { cn } from "@/lib/utils";
// ========================================
// HEALTH BAR COMPONENT
// ========================================
const pixelHealthBarVariants = cva(
"relative border-4 border-black shadow-[4px_4px_0px_0px_rgba(0,0,0,1)]",
{
variants: {
variant: {
default: "bg-white dark:bg-[#2a2a2a]",
outlined: "bg-transparent",
},
size: {
sm: "h-6",
md: "h-8",
lg: "h-12",
},
},
defaultVariants: {
variant: "default",
size: "md",
},
},
);
export interface PixelHealthBarProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof pixelHealthBarVariants> {
current: number;
max: number;
showLabel?: boolean;
label?: string;
color?: string;
}
const PixelHealthBar = React.forwardRef<HTMLDivElement, PixelHealthBarProps>(
(
{
className,
variant,
size,
current,
max,
showLabel = true,
// ... (more code below)Props
| Prop | Type | Default | Description |
|---|---|---|---|
| current | number | - | Current health/mana value |
| max | number | - | Maximum health/mana value |
| currentXP | number | - | Current experience points |
| requiredXP | number | - | XP required for next level |
| level | number | - | Character level |
| columns | 3 | 4 | 5 | 6 | 5 | Inventory grid columns |
| rarity | "common" | "rare" | "epic" | "legendary" | - | Item rarity |
| variant | "bronze" | "silver" | "gold" | "platinum" | - | Achievement tier |
Examples
Health Bar
HP bar with auto-coloring
🧙
Wizard
Level 12
HP85/100
MP60/100
XP350/500
Inventory
⚔️
🛡️
💊5
🔮
👑
50
25
100!
XP Bar
Experience bar with level
🧙
Wizard
Level 12
HP85/100
MP60/100
XP350/500
Inventory
⚔️
🛡️
💊5
🔮
👑
50
25
100!
Inventory
Grid-based inventory system
🧙
Wizard
Level 12
HP85/100
MP60/100
XP350/500
Inventory
⚔️
🛡️
💊5
🔮
👑
50
25
100!
Achievement
Trophy notification
🧙
Wizard
Level 12
HP85/100
MP60/100
XP350/500
Inventory
⚔️
🛡️
💊5
🔮
👑
50
25
100!
Accessibility
This component is built with accessibility in mind, including proper ARIA attributes, keyboard navigation, and focus management.