Rainbow Card
Animated rainbow gradient border effect — the exact same animation used in the Button rainbow effect. Drop <RainbowBorder /> inside any Card and apply rainbowCardClasses to the Card.
Installation
Section titled “Installation”npx shadcn@latest add https://joaocarmassi.com/components/rainbow-border.jsonpnpm dlx shadcn@latest add https://joaocarmassi.com/components/rainbow-border.jsonnpx shadcn@latest add https://joaocarmassi.com/components/rainbow-border.jsonbunx --bun shadcn@latest add https://joaocarmassi.com/components/rainbow-border.jsonImport
Section titled “Import”import { RainbowBorder, rainbowCardClasses,} from '@/components/ui/rainbow-border';import { Card, CardHeader, CardTitle, CardDescription, CardContent,} from '@/components/ui/card';import { cn } from '@/lib/utils';Preview
Section titled “Preview”Rainbow Card
Animated rainbow gradient border.
Same rainbow effect as the Button component.
<Card className={cn('relative w-[320px]', rainbowCardClasses)}> <RainbowBorder /> <CardHeader> <CardTitle>Rainbow Card</CardTitle> <CardDescription className='text-primary-foreground/70'> Animated rainbow gradient border. </CardDescription> </CardHeader> <CardContent> <p className='text-sm text-primary-foreground/70'> Same rainbow effect as the Button component. </p> </CardContent></Card>How it works
Section titled “How it works”rainbowCardClassesis a string of Tailwind classes that apply the rainbow gradient to the Card’s background/border.<RainbowBorder />renders the decorative blurred glow beneath the card.- The card body adapts to themes automatically (dark body in light mode, light body in dark mode).
rainbowCardClasses
Section titled “rainbowCardClasses”A constant string of Tailwind classes. Apply it to the Card’s className alongside relative.
<RainbowBorder />
Section titled “<RainbowBorder />”A zero-prop decorative element. Drop it as a child of the Card.