Shows an image as a solid silhouette and smoothly reveals it on click, on hover or from your state. The silhouette is a CSS mask cut from the image itself and filled with the text color, so it stays visible in both light and dark themes. It is a server component with no JavaScript: a click checks a hidden checkbox, hover is :hover and :focus-visible, and :has() switches the layers.
Browser Support
Reveals the image through a silhouette.
Changes the reveal on interaction.
Preview
Installation
Usage
import { SilhouetteReveal } from "@/components/ui/silhouette-reveal"
export default function Example() {
return (
<SilhouetteReveal
src="/images/mascot.png"
alt="Our mascot"
className="size-48"
/>
)
}Examples
Guess who
A quiz round: the silhouette stays hidden until the right answer. trigger="manual" with your own state, so a wrong answer can shake the card and a right one sets revealed.
const [solved, setSolved] = useState(false)
<SilhouetteReveal
src="/images/owl.svg"
alt="Owl"
trigger="manual"
revealed={solved}
className="size-64"
/>
{options.map((option) => (
<Button
key={option.id}
variant="outline"
onClick={() => {
if (option.id === "owl") {
setSolved(true)
customToast.success("Correct! It's an owl")
} else {
customToast.error("Not quite, try again")
}
}}
>
{option.name}
</Button>
))}Hidden prize
A gift card with a hidden product. The button flips revealed, and the promo code appears together with the image.
const [open, setOpen] = useState(false)
<Card>
<CardHeader>
<CardTitle>Your gift is waiting</CardTitle>
<Badge variant="beta">Gift</Badge>
</CardHeader>
<CardContent>
<SilhouetteReveal
src="/images/headphones.svg"
alt="Wireless headphones"
trigger="manual"
revealed={open}
duration={1100}
className="size-44"
/>
{open && <code>GOOSE-2026</code>}
</CardContent>
<CardFooter>
<Button onClick={() => setOpen(true)}>Open the gift</Button>
</CardFooter>
</Card>Collection teaser
Three "Soon" cards. trigger="hover" needs no state at all, and the product name unblurs with :has() on the same hover.
New collection
Hover a card to peek at what is coming
Trail sneaker
Soon12 Dec
City backpack
Soon19 Dec
Desk lamp
Soon26 Dec
<Card className="group/drop">
<CardContent>
<SilhouetteReveal
src="/images/sneaker.svg"
alt="Trail sneaker"
trigger="hover"
duration={500}
className="size-32"
/>
{/* Unblurs while the image inside is hovered or focused */}
<p className="blur-sm transition-[filter] group-has-[[data-gooseui-silhouette]:is(:hover,:focus-visible)]/drop:blur-none">
Trail sneaker
</p>
<Badge variant="info" size="sm">Soon</Badge>
</CardContent>
</Card>Achievements
Locked achievements stay a muted silhouette, the unlocked one is revealed. The silhouette color comes from silhouetteClassName.
First win
Win your first match
???
Play 7 days in a row
???
Play 100 matches
{achievements.map((item) => (
<div key={item.id}>
<SilhouetteReveal
src={item.image}
alt={item.name}
trigger="manual"
revealed={item.done}
silhouetteClassName="text-muted-foreground/35"
className="size-24"
/>
<p>{item.done ? item.name : "???"}</p>
<Badge variant={item.done ? "success" : "neutral"}>
{item.done ? "Unlocked" : item.progress}
</Badge>
</div>
))}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | - | Image URL, ideally with a transparent background |
| alt | string | - | Alt text shown after the reveal |
| revealed | boolean | - | Reveal from outside; with manual it is the only switch |
| defaultRevealed | boolean | false | Start revealed in click mode |
| trigger | "click" | "hover" | "manual" | "click" | What reveals the image |
| duration | number | 700 | Transition duration in ms |
| name | string | - | Name of the click checkbox, so the state reaches FormData |
| silhouetteClassName | string | - | Classes for the silhouette, set its color with text-* |
| imageClassName | string | - | Classes for the <img> element |
| labels | Partial<SilhouetteRevealLabels> | English | Trigger label and alt text while hidden |
| className | string | - | Classes for the root. Give it a size, for example size-48 |
Features
- Theme-safe silhouette: a mask filled with currentColor instead of brightness(0), so it never disappears on a dark background
- No spoilers: while hidden, the image alt is replaced with a neutral text
- Three triggers: click, hover with focus, or manual control
- No JavaScript: the reveal works before hydration and with scripts turned off. To react to it, listen to the change event that bubbles from the checkbox
- Accessible: click mode is a labelled checkbox, Space reveals it, hover mode reacts to keyboard focus
- Reduced motion: the reveal happens without the transition