Streak Card
trophy/streak-cardFreeComponent
Full streak UI card for React. Daily streak display, longest streak record with optional section for streak rules. 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/streak-card.jsonSource
1"use client"23import * as React from "react"4import {5 CheckCircle2,6 ChevronDown,7 ChevronRight,8 Flame,9 RefreshCcw,10} from "lucide-react"1112import { cn } from "@/lib/utils"13import { Button } from "@/components/ui/button"14import {15 StreakCalendar,16 type StreakPeriod,17} from "@/components/ui/streak-calendar"1819interface StreakCardProps extends React.HTMLAttributes<HTMLDivElement> {20 /** Streak periods passed through to StreakCalendar */21 streak: StreakPeriod[]22 /** Current streak value in days */23 currentStreak: number24 /** Longest streak value in days */25 longestStreak: number26 /** Secondary total metric value */27 total: number28 /** Optional heading text */29 title?: string30 /** Label for the action button */31 actionLabel?: string32 /** Callback for action click */33 onActionClick?: () => void34 /** Show "How streaks work" dropdown section */35 showHowItWorks?: boolean36 /** Title for the dropdown trigger */37 howItWorksTitle?: string38 /** Content rows shown when the dropdown is expanded */39 howItWorksItems?: string[]40 /** Initial expanded state for dropdown */41 defaultHowItWorksOpen?: boolean42}4344const StreakCard = React.forwardRef<HTMLDivElement, StreakCardProps>(45 (46 {47 className,48 streak,49 currentStreak,50 longestStreak,51 total,52 title = "Streak",53 actionLabel = "View Details",54 onActionClick,55 showHowItWorks = true,56 howItWorksTitle = "How do streaks work?",57 howItWorksItems = [58 "Complete at least one activity each day to build your streak.",59 "Each day you do an activity, your streak increases.",60 "Missing a day will reset your streak to 0.",61 ],62 defaultHowItWorksOpen = false,63 ...props64 },65 ref66 ) => {67 const [isHowItWorksOpen, setIsHowItWorksOpen] = React.useState(68 defaultHowItWorksOpen69 )70 const howItWorksContentId = React.useId()7172 return (73 <section74 ref={ref}75 aria-label="Streak summary card"76 className={cn("bg-card rounded-2xl border p-6 shadow-sm", className)}77 {...props}78 >79 <header className="mb-3 flex items-center justify-between gap-3">80 <div className="flex items-center gap-2">81 <Flame className="text-primary h-6 w-6" aria-hidden="true" />82 <h3 className="text-2xl leading-none font-semibold">{title}</h3>83 </div>84 <Button85 variant="link"86 size="sm"87 onClick={onActionClick}88// … truncated
What it pulls in
npm packages
Other registry items
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 |
