Cookie consentNew
A cookie banner with a mascot: every cookie you allow flies to Crumb, who catches it, nibbles it and gets rounder and happier.
Used forCookie bannersPrivacy settingsPlayful brandsLaunch pages
Install with the shadcn CLI
Older shadcn CLI, or a network that blocks ui.shadcn.com? Install by URL: shadcn add https://hairlineui.com/r/cookie-consent.json. More
Templates
Need the whole page?
65 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
Cookie banners
The first-visit consent card, in a corner or centred, with a mascot people play with.
Privacy settings
The cookie preferences page people come back to, with the same choices.
Playful brands
Consumer apps, games and shops whose voice is warmer than a legal notice.
Launch pages
A consent card that gets shared instead of skipped.
What it handles for you
A cookie banner is usually a paragraph, a Customise link and a modal of switches nobody reads. This block keeps the categories on one card, makes rejecting as easy as accepting, and gives every choice a reaction.
A reaction to every choice
Each category switched on sends Crumb a cookie; switched off, it hands the cookie back with a bite out of it.
A mood you can read
Crumb gets rounder and happier with each cookie: hungry, content, then stuffed and sparkling.
Reject as easy as Accept
Reject all sits beside the main button at the same size, and nothing optional is on until someone says so.
Necessary, plainly
Required categories show Always on and can’t be switched off.
The right button
The main button reads Accept all, or Save choices once some but not all are on; both go Saving → Saved.
Kept your way
onSave gets { [category]: on } for a cookie, your consent platform or your API; a failure shakes and says why.
Overview
Cookie banners are the most skipped screen on the web. This one gives the choice a face. Crumb, an animated bread bun with a golden top, sits on the lit stage with his hands clasped, pleading, hungry. Switch Analytics on and a chocolate-chip cookie leaps from the switch and spins over the card into his hands, and he eats it: bite after bite, the cookie shrinking, crumbs dropping at his feet, then he chews and settles a little fuller. Each cookie plays the next of three eating clips, from hungry to content to full to stuffed, his cheeks puffing a little more each time. Switch one back off and the bitten cookie flies back to its switch while he eases back to how full he was. Reject all hands every cookie back; Accept all feeds the rest. Under the fun it is a proper consent banner: Necessary is always on and says so, Reject all sits beside the main button at the same size, the main button reads Accept all or Save choices depending on what you picked, and onSave gets the choices to keep wherever you keep them.
States
- hungry
- Crumb sits on the lit stage, hands clasped under his chin, big pleading eyes, breathing; the line above reads “Crumb is hungry”.
- feed
- A switch on: a chocolate-chip cookie pops out of it and spins along an arc over the card (620ms) into his hands; he leans toward it as it comes.
- eat
- The next eating clip takes over from the frame with the cookie in his hands and plays at 10 frames a second for 1.8s: three bites, the cookie shrinking, crumbs falling, chewing, then he settles a little fuller.
- content / stuffed
- Three clips take him from hungry to content to full to stuffed, his cheeks rounder each time; with every category on, “Crumb is stuffed”. Any number of categories maps onto the three.
- give back
- A switch off: the bitten cookie flies from him back to its switch (640ms) and he cross-fades back to how full he was.
- reject / accept all
- Reject all hands every cookie back, 140ms apart; Accept all feeds the rest, 170ms apart; the choices are saved once they have landed.
- saved
- The button goes Saving → Saved with a drawn check and Crumb gives a happy hop.
- not saved
- If onSave throws, the button shakes into Try again and your message replaces the line under it.
Usage
Works with
Installs with it
- Status buttonSave, Saving, Saved: the spinner opens in, the check draws itself, errors shake, and the label morphs between them.
- SwitchA switch with weight: the thumb stretches on press, is thrown across with a slight overshoot, and spins while an async save settles.
- Text morphText that changes the way it should: shared letters slide over, new ones rise out of a blur, the width eases.
Show it once, then load scripts by consent
Show the block until there is a consent cookie, keep the choices in it, and only load analytics and marketing scripts for the categories that are on.
Props
- onSave
- (choices: CookieChoices) => Promise<unknown>
- Gets { [category id]: boolean } with required categories true. Keep it; throw an Error to show its message.
- categories= Necessary, Analytics, Marketing, Personalization
- CookieCategory[]
- { id, label, description?, required? }. Required ones show Always on; each other one is a cookie for Crumb.
- value / defaultValue / onValueChange= — / {} (all optional off)
- CookieChoices
- The choices, controlled or not.
- title / description= "Cookie settings" / "Every cookie you allow goes to Crumb."
- string
- The heading and the line under it.
- name= "Crumb"
- string
- What the mascot is called in its lines.
- policyHref
- string
- Links “Cookie policy” under the buttons.
Accessibility and motion
- Each category is a real switch labelled by its name; the mascot is decoration (aria-hidden) and each change is announced from a status region (“Analytics allowed.”).
- Nothing optional is on by default, and Reject all is the same size as the main button, side by side.
- Crumb is three short eating clips cut into transparent WebP frame strips (about 200KB of images, with the cookie art) inside crumb-art.ts, so the install is complete. One frame loop outside React steps the frames, flies the cookies in an overlay over the card and sleeps when he’s still; nothing costs React renders.
- The stage is the lit --primary surface in your theme, light or dark; the crumbs and the pool of light under him are --crumb-* variables you can override. No drop shadows, glow or blur.
- Built from Switch, Status button and Text morph, which the CLI installs with it. No animation library; with reduced motion nothing flies and Crumb’s mood changes in place.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Status button, Switch, Text morph.
Source
Registry item: /r/cookie-consent.json


