Celebratory React dialog for newly unlocked milestones with headline, badge, and share actions. Use for unlock moments, level up animations and more. Built on shadcn/ui + Tailwind. Open source.
Milestone Unlocked is a focused celebration moment for newly reached milestones—level up animations, congratulating users, reinforcing rewards, and encouraging sharing at the moments that matter most in the user journey.
Installation
npx shadcn@latest add https://ui.trophy.so/milestone-unlockedUsage
import { MilestoneUnlocked } from "@/components/ui/milestone-unlocked"const [open, setOpen] = useState(false)
<button
type="button"
onClick={() => setOpen(true)}
className="rounded-lg border bg-background px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-muted"
>
Unlock milestone
</button>
<MilestoneUnlocked
milestone={{
id: "task-champion",
name: "Task Champion",
description: "Complete a task 30 days in a row. Congratulations!!",
unlockedAt: new Date().toISOString(),
}}
open={open}
onOpenChange={setOpen}
secondaryActionLabel="Share"
onSecondaryActionClick={() => {
navigator.share?.({
title: "I unlocked Task Champion!",
text: "Complete a task 30 days in a row. Congratulations!!",
url: window.location.href,
})
}}
/>Examples
Basic Usage
const [open, setOpen] = useState(false)
<button
type="button"
onClick={() => setOpen(true)}
className="rounded-lg border bg-background px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-muted"
>
Unlock milestone
</button>
<MilestoneUnlocked
milestone={{
id: "task-champion",
name: "Task Champion",
description: "Complete a task 30 days in a row. Congratulations!!",
unlockedAt: new Date().toISOString(),
}}
open={open}
onOpenChange={setOpen}
/>With Trophy
Use the Trophy SDK to send a metric event server-side. Any milestones the event completes are returned in the response's achievements field:
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.metrics.event(
"words-written",
{
user: {
id: 'user-id',
email: '[email protected]',
tz: 'Europe/London',
subscribeToEmails: true,
attributes: {
department: 'engineering',
role: 'developer'
}
},
value: 750,
attributes: {
category: 'writing',
source: 'mobile-app'
}
}
);
Then pass and transform the response into MilestoneUnlocked props in your UI layer:
const unlockedMilestone = response.achievements?.[0]
const shouldOpen = Boolean(unlockedMilestone)
{
unlockedMilestone ? (
<MilestoneUnlocked milestone={unlockedMilestone} open={shouldOpen} />
) : null
}API Reference
MilestoneUnlocked
| Prop | Type | Default | Description |
|---|---|---|---|
milestone | Milestone | Required | The milestone to display |
open | boolean | Required | Controls dialog visibility |
onOpenChange | (open: boolean) => void | Required | Called when open state changes |
secondaryActionLabel | string | "Share" | Label for the secondary action button |
onSecondaryActionClick | () => void | - | Secondary button click handler for social share or custom actions |
onShare | () => void | - | Deprecated alias for onSecondaryActionClick |
className | string | - | Additional classes for the dialog |
Milestone
interface Milestone {
id: string
name: string
description?: string | null
unlockedAt?: string
}Power in-app personalization with Trophy
Trophy is the 1:1 customer engagement platform for consumer web and mobile apps: in-app streaks, milestones, points and leaderboards, plus AI lifecycle agents that personalize every message.
Get Started