BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/trophy/points-badge

Points Badge

trophy/points-badge
FreeComponent

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.

Live preview

live · rendered by the registry
Rendered by trophy on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://ui.trophy.so/r/points-badge.json

Source

registry/trophy/ui/points-badge.tsxui.trophy.so/r/points-badge.json
1"use client"
2
3import * as React from "react"
4import { cva, type VariantProps } from "class-variance-authority"
5import { Sparkle } from "lucide-react"
6
7import { cn } from "@/lib/utils"
8
9const pointsBadgeVariants = cva(
10 "flex items-center gap-3 rounded-lg transition-colors",
11 {
12 variants: {
13 size: {
14 sm: "text-sm gap-2",
15 default: "",
16 lg: "text-lg gap-4",
17 },
18 },
19 defaultVariants: {
20 size: "default",
21 },
22 }
23)
24
25interface PointsBadgeProps
26 extends
27 React.HTMLAttributes<HTMLDivElement>,
28 VariantProps<typeof pointsBadgeVariants> {
29 name: string
30 total: number
31 /** When omitted or `null`, the default icon is shown instead of an image. */
32 badgeUrl?: string | null
33 icon?: React.ComponentType<{ className?: string }>
34 formatValue?: (value: number) => string
35}
36
37const PointsBadge = React.forwardRef<HTMLDivElement, PointsBadgeProps>(
38 (
39 {
40 className,
41 size,
42 name,
43 badgeUrl,
44 total,
45 icon: CustomIcon,
46 formatValue,
47 ...props
48 },
49 ref
50 ) => {
51 const Icon = CustomIcon ?? Sparkle
52 const displayValue = formatValue
53 ? formatValue(total)
54 : total.toLocaleString()
55
56 const iconSize = {
57 sm: "h-4 w-4",
58 default: "h-5 w-5",
59 lg: "h-6 w-6",
60 }[size ?? "default"]
61
62 const badgeSize = {
63 sm: "h-6 w-6",
64 default: "h-8 w-8",
65 lg: "h-10 w-10",
66 }[size ?? "default"]
67 const statusLabel = `${displayValue} ${name}`
68
69 return (
70 <div
71 ref={ref}
72 role="status"
73 aria-label={statusLabel}
74 className={cn(
75 pointsBadgeVariants({ size }),
76 "bg-card border p-4",
77 className
78 )}
79 {...props}
80 >
81 <div className="flex items-center gap-2">
82 {badgeUrl ? (
83 <div>
84 <img
85 src={badgeUrl}
86 alt=""
87 aria-hidden="true"
88 className={cn("shrink-0 rounded object-contain", badgeSize)}
89 />
90 </div>
91 ) : (
92 <div
93 aria-hidden="true"
94 className={cn(
95 "bg-primary/10 flex shrink-0 items-center justify-center rounded-full",
96 badgeSize
97 )}
98 >
99 <Icon className={cn(iconSize, "text-primary")} />
100 </div>
101 )}
102
103 <div>
104 <span
105 className={cn(
106 "font-bold tabular-nums",
107// … truncated

What it pulls in

npm packages

  • class-variance-authority
  • lucide-react

Files it writes

  • registry/trophy/ui/points-badge.tsx

Facts

Registry
trophy
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
today

Go to the source

Docs on trophy ui.trophy.so trophyso/ui on GitHub Raw registry item This item as JSON

More from trophy

All 18 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Achievement Badgeachievement-badgetrophyComponentsFree1 dep
Achievement Cardachievement-cardtrophyComponentsFreeno deps
Achievement Gridachievement-gridtrophyComponentsFree2 deps
Achievement Listachievement-listtrophyComponentsFree2 deps
Achievement Unlockedachievement-unlockedtrophyComponentsFree1 dep
Leaderboard Cardleaderboard-cardtrophyComponentsFreeno deps
Leaderboard Podiumleaderboard-podiumtrophyComponentsFree2 deps
Leaderboard Rankingsleaderboard-rankingstrophyComponentsFree2 deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex