Points Awards
trophy/points-awardsFreeComponent
React points activity feed with dated events, totals, and trigger types for gamification timelines. Useful for XP and currency ledgers in dashboards. 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-awards.jsonSource
1"use client"23import * as React from "react"4import * as TooltipPrimitive from "@radix-ui/react-tooltip"5import {6 Award,7 Clock,8 Flame,9 Sparkles,10 Target,11 UserPlus,12 type LucideIcon,13} from "lucide-react"1415import { cn } from "@/lib/utils"1617export interface PointsAwardTrigger {18 id: string19 type: string20 points: number21 metricName?: string | null22 metricThreshold?: number | null23 achievementName?: string | null24 streakLengthThreshold?: number | null25 timeUnit?: "hour" | "day"26 timeInterval?: number | null27}2829export interface PointsAward {30 id: string31 awarded: number32 /** ISO 8601 datetime */33 date: string34 /** User's total points after this award */35 total: number36 trigger: PointsAwardTrigger37}3839interface PointsAwardsProps extends React.HTMLAttributes<HTMLDivElement> {40 awards: PointsAward[]41 formatTotalPoints?: (value: number) => string42 formatAwardedPoints?: (value: number) => string43 /** Format the award `date` for the first column (default: short locale date). */44 formatDate?: (isoDate: string) => string45}4647const TooltipProvider = TooltipPrimitive.Provider48const Tooltip = TooltipPrimitive.Root49const TooltipTrigger = TooltipPrimitive.Trigger50const TooltipContent = React.forwardRef<51 React.ElementRef<typeof TooltipPrimitive.Content>,52 React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>53>(({ className, sideOffset = 6, ...props }, ref) => (54 <TooltipPrimitive.Content55 ref={ref}56 sideOffset={sideOffset}57 className={cn(58 "bg-popover text-popover-foreground z-50 max-w-xs overflow-hidden rounded-md border px-3 py-1.5 text-xs shadow-md",59 "animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",60 "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",61 className62 )}63 {...props}64 />65))66TooltipContent.displayName = TooltipPrimitive.Content.displayName6768const triggerIconMap: Record<string, LucideIcon> = {69 metric: Target,70 achievement: Award,71 streak: Flame,72 time: Clock,73 user_creation: UserPlus,74}7576function triggerIcon(type: string): LucideIcon {77 return triggerIconMap[type] ?? Sparkles78}7980/** Human-readable action line for tooltips — prefers `metricName` when present. */81function awardActionDescription(trigger: PointsAwardTrigger): string {82 if (trigger.metricName) {83 if (84// … truncated
What it pulls in
npm packages
Files it writes
More from trophy
All 18 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Achievement Badgeachievement-badge | trophy | Components | Free | 1 dep | |
| Achievement Cardachievement-card | trophy | Components | Free | no deps | |
| Achievement Gridachievement-grid | trophy | Components | Free | 2 deps | |
| Achievement Listachievement-list | trophy | Components | Free | 2 deps | |
| Achievement Unlockedachievement-unlocked | trophy | Components | Free | 1 dep | |
| Leaderboard Cardleaderboard-card | trophy | Components | Free | no deps | |
| Leaderboard Podiumleaderboard-podium | trophy | Components | Free | 2 deps | |
| Leaderboard Rankingsleaderboard-rankings | trophy | Components | Free | 2 deps |
