Combos
Components here are small on purpose and meet at the edges: wrap one in another, or call one from another. Nothing needs a special prop to work with the rest.
Confetti on a button
<Confetti> wraps one element and fires from its center on an event. The button does not know about it, so it works with Button, AvatarButton or any element that passes its handlers through.
combo-confetti-button.tsx
"use client";
import { Button } from "@/components/ui/button";
import { Confetti } from "@/components/ui/confetti";
export default function ComboConfettiButton() {
return (
<div className="flex flex-wrap items-center justify-center gap-4">
<Confetti>
<Button variant="cartoon">Cartoon button</Button>
</Confetti>
<Confetti count={30} on="pointerenter" spread={120}>
<Button variant="outline">Burst on hover</Button>
</Confetti>
</div>
);
}Avatar and Button
AvatarButton is a Button with an Avatar inside, nothing more. It takes every Button prop, so it also takes a wrapper. Here it is inside <Confetti>.
combo-avatar-confetti.tsx
"use client";
import { AvatarButton } from "@/components/ui/avatar-button";
import { Confetti } from "@/components/ui/confetti";
export default function ComboAvatarConfetti() {
return (
<div className="pt-4">
<Confetti shapes={["star", "circle"]}>
<AvatarButton blink fallback="CD" src="/avatar-cartoon.svg">
Ship it
</AvatarButton>
</Confetti>
</div>
);
}A toast that celebrates
Toast and Confetti stay separate. Call both from the same handler and aim the burst at the corner where the toast appears.
combo-celebrate-toast.tsx
"use client";
import { Button } from "@/components/ui/button";
import { confetti } from "@/components/ui/confetti";
import { ToastProvider, useToast } from "@/components/ui/toast";
function CelebrateButton() {
const toast = useToast();
return (
<Button
onClick={() => {
toast.add({ title: "Level up!", description: "You reached level 8.", type: "success" });
// The toast stack lives in the bottom-right corner: the burst starts there.
confetti({ origin: { x: window.innerWidth - 140, y: window.innerHeight - 60 }, angle: 235, spread: 60 });
}}
variant="cartoon"
>
Level up
</Button>
);
}
export default function ComboCelebrateToast() {
return (
<ToastProvider>
<CelebrateButton />
</ToastProvider>
);
}One set of tokens
Button, Badge and Card share the cartoon variables. Set them on a parent and everything inside follows. The full list is on the Theme page.
One set of tokens
Three variables on the card restyle everything inside it.
combo-cartoon-set.tsx
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
export default function ComboCartoonSet() {
return (
<Card className="w-full max-w-sm [--cartoon-border:3px] [--cartoon-ink:#4c1d95] [--cartoon-offset:6px]" variant="cartoon">
<CardHeader>
<CardTitle>One set of tokens</CardTitle>
<CardDescription>Three variables on the card restyle everything inside it.</CardDescription>
</CardHeader>
<CardContent className="flex flex-wrap items-center gap-3">
<Badge variant="cartoon">purple ink</Badge>
<Button variant="cartoon">Fat shadow</Button>
</CardContent>
</Card>
);
}How they fit
Three rules keep the combos honest: a wrapper clones its child instead of adding markup, a variant is a class and not a new component, and motion always comes from the shared tokens, so reduced motion turns it all off in one place.