React streak counter UI in a compact badge supporting daily, weekly, monthly or yearly streaks. Built on shadcn/ui + Tailwind. Open source.
The Streak Badge is a compact building block for streak gamification UI in React. Display current streak length, embed optional flame or custom icons, and control layout for habit tracking and engagement gamification flows. Compose with Streak Card or Streak Calendar when you need streak gamification UI at scale.
7daysstreak
Installation
npx shadcn@latest add https://ui.trophy.so/streak-badgeUsage
Import the component:
import { StreakBadge } from "@/components/ui/streak-badge"Basic usage with a streak length:
7daysstreak
Examples
Basic Usage
7daysstreak
<StreakBadge length={7} />Sizes
Available in three sizes: sm, default, and lg.
7daysstreak
7daysstreak
7daysstreak
With Trophy
Use the Trophy SDK to fetch streak data for a particular user server-side:
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.users.streak("user-id", {
historyPeriods: 14
});
Then pass response fields into StreakBadge in your UI layer:
<StreakBadge length={response.length} frequency={response.frequency} />API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
length | number | - | Streak length value |
frequency | "daily" | "weekly" | "monthly" | "daily" | Frequency label used to render streak description |
size | "sm" | "default" | "lg" | "default" | Badge size |
icon | ReactNode | - | Custom icon to replace flame |
Types
interface StreakResponse {
length: number
frequency: "daily" | "weekly" | "monthly"
}Power Gamification with Trophy
Trophy powers the infrastructure you need to ship reliable gamification features at scale.
Get Started