
Notifications · Free
Bot cookies
A cookie banner where the cookie is the consent: chips for each kind you allow, the Bot eats it on Accept all; jelly switches, remembers the choice and calls onChoice.
Free on Gumroad: the download arrives in your inbox.
Details
- Category
- Notifications
- Plan
- Free
- Code
- React + Tailwind, TypeScript · 275 lines
- Files
- BotCookies.tsx
- Needs
- The Bot (installed with it)
- Agents
- MCP server and shadcn registry
About
A cookie banner where the Bot holds the cookie, and the cookie is the consent. Every kind of cookie you allow adds its chocolate chips; every one you turn off takes them away. Accept all and the Bot eats it, bite by bite, happy. Only the necessary ones and it keeps a plain biscuit and nods. Customize opens a jelly switch for each kind.
It remembers the choice (localStorage), so it doesn't ask again, and tells your code with onChoice.
Install
With the shadcn CLI:
npx shadcn@latest add https://www.stackd.codes/r/bot-cookies.jsonOr let your agent add it through the StackD MCP server:
claude mcp add --transport http stackd https://www.stackd.codes/mcpPrompt for your agent
Paste it into Claude Code, Cursor, Codex or VS Code once the MCP server is connected.
Add the StackD Bot cookies component to this project. Use the StackD MCP server: call get_component with { "name": "bot-cookies" }, write the files at the paths it gives and install any npm packages it lists. Then use it where it fits, following its README for the props, and keep its own styles.What's inside
| File | What it is |
|---|---|
BotCookies.tsx | The banner |
Bot.tsx | The Bot that holds the cookie |
Use
- Copy both files into the same folder of your project (for example
components/). - Put it once in your layout:
import { BotCookies } from './components/BotCookies'
<BotCookies
policyHref="/cookies"
onChoice={(choice) => {
// { necessary: true, analytics: boolean, marketing: boolean, preferences: boolean }
if (choice.analytics) startAnalytics()
}}
/>
On later visits, read the saved choice yourself before loading anything:
const saved = JSON.parse(localStorage.getItem('stackd-cookies') ?? 'null')
In Next.js the files already start with 'use client'. In other React setups that line does nothing.
Options
| Prop | Default | What it does |
|---|---|---|
title | 'We use cookies' | The heading |
body | a short sentence | The text under it |
policyHref | Your cookie policy. Without it there's no link | |
kinds | four kinds | Names and descriptions of necessary, analytics, marketing, preferences |
onChoice | Called with the choice, after the Bot's little scene | |
storageKey | 'stackd-cookies' | Where the choice is kept. null: not kept, it asks every time |
alwaysShow | false | Show it even if a choice is kept (for a settings page or a demo) |
defaultOpen | false | Start with the switches open |
defaultChoice | all on | The switches as they start, e.g. { marketing: false } |
floating | true | Fixed in the bottom-left corner. false puts it where you place it |
theme | 'light' | 'light' or 'dark' |
className | Extra classes |
Good to know
The banner records the choice; it doesn't block scripts by itself. Load analytics or ads only when onChoice (or the saved choice) says yes. Check what your country's rules ask for; this gives people a clear, equal choice between accepting and refusing.
Works with
Mouse, touch and keyboard. It's a dialog with a heading, and the kinds are real switches (role="switch"), so screen readers say on or off. With reduced motion on, the Bot doesn't animate: the choice is made straight away.

