Compact React points badge for totals and currency-style scores in gamification UIs. Fits XP-style displays alongside charts and lists. Built on shadcn/ui + Tailwind. Open source.
The Points Badge is a lightweight gamification readout for points and XP totals—use it anywhere gamification scores need a compact header. Compose with Points Chart or Points Levels List when users need headline totals plus deeper progress gamification elsewhere in the layout.
2,500
XP
Installation
npx shadcn@latest add https://ui.trophy.so/points-badgeUsage
Import the component:
import { PointsBadge } from "@/components/ui/points-badge"Examples
Basic Usage
2,500
XP
<PointsBadge name="XP" total={2500} />Sizes
Available in three sizes: sm, default, and lg.
1,250
XP
1,250
XP
1,250
XP
<PointsBadge name="XP" total={1250} size="sm" />
<PointsBadge name="XP" total={1250} size="default" />
<PointsBadge name="XP" total={1250} size="lg" />With Trophy
Use the Trophy SDK to fetch the user's points total server-side:
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.points("user-id", "points-system-key");
Then pass the response into PointsBadge props in your UI layer:
<PointsBadge
name={response.name}
badgeUrl={response.badgeUrl}
total={response.total}
/>API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | Required | Label for the points (e.g. currency name) |
badgeUrl | string | null | - | Optional badge image URL; omit or pass null to show the default icon |
total | number | Required | Points total to display |
size | "sm" | "default" | "lg" | "default" | Component size |
icon | ComponentType | - | Custom icon component when no badge image is available |
formatValue | (value: number) => string | - | Custom value formatter |
Power Gamification with Trophy
Trophy powers the infrastructure you need to ship reliable gamification features at scale.
Get Started