AI Cookie横幅生成器。

描述您需要的Cookie同意体验 — 横幅样式、按钮标签、法律文案、配色方案 — MeDo即刻生成生产就绪的代码。无需模板即可发布合规的、符合品牌的Cookie横幅。

Cookie横幅
Cookie横幅

Cookie横幅是法律要求的 — 而且通常做得很糟糕。

GDPR、CCPA和ePrivacy法规要求在设置非必要Cookie之前获得知情同意,监管机构正在积极执法。但大多数Cookie横幅使用暗模式、丑陋或有缺陷。一个设计良好的同意横幅能建立用户信任、减少侵入性弹窗造成的跳出,并在不牺牲体验的情况下保持网站合规。MeDo帮助您生成一个看起来是精心设计的横幅,而不是临时拼凑的。

6 个模板

可以生成的 Cookie横幅 模板

每个模板都是真实的提示词,而不是截图。复制到任意 AI 编辑器,或在 MeDo 中运行,直接拿到 React + Tailwind 代码。

Bottom barBaseline

Accept and Reject Bottom Bar

One line of copy, two buttons of equal weight, a policy link. The smallest banner that still gives a genuine choice rather than a dismiss disguised as one.

Create a cookie consent bar fixed to the bottom of the viewport: a short line explaining that non-essential cookies are used for analytics, a link to the cookie policy, and two buttons — Accept all and Reject non-essential — rendered with identical size, contrast and padding so neither is visually demoted. Render it in a region with role="region" and an accessible name, do not trap focus, and place it last in the DOM so it does not sit ahead of the page content in tab order. Persist the decision under a versioned key in localStorage with a timestamp, and keep the bar hidden on every later visit until that version changes. Load no analytics script before a decision exists.

在 MeDo 中尝试
CategoriesGranular

Per-Category Consent Panel

Four categories, three of them off until someone turns them on. The version to build when tags actually differ in purpose rather than all being one analytics script.

Create a cookie consent panel with four categories: Necessary (locked on, with a note explaining it cannot be disabled), Functional, Analytics and Marketing, each a labelled switch with a one-sentence description of what it enables. Every non-essential switch defaults to off. Provide Accept all, Reject all and Save preferences, with Accept all and Reject all identical in weight. Store the result as an object keyed by category alongside a schema version and timestamp, and emit a consent-changed event so tag loading can react without a page reload. Keep the switches keyboard operable with visible focus rings and expose state through aria-checked rather than colour alone.

在 MeDo 中尝试
ModalGate

Centered Consent Modal

Blocks the page until a choice is made. Highest completion rate, highest bounce rate — reach for it only when a decision genuinely has to precede the first render.

Create a centered cookie consent modal with a dimmed backdrop: heading, two sentences of explanation, a cookie policy link, and Accept all, Reject all and Manage preferences buttons with the first two given equal visual weight. Use role="dialog" with aria-modal="true", label it by its heading, move focus to the heading on open, cycle Tab within the dialog, and do not close on Escape or backdrop click since either would leave consent undecided. Persist the choice in a versioned localStorage record with a timestamp and render nothing on subsequent visits. Do not pre-tick any non-essential category, and gate every non-essential script behind the stored value.

在 MeDo 中尝试
ToastCorner

Corner Card Consent Toast

A small card in the bottom corner that leaves the page usable. Least disruptive and least answered — expect a large share of visitors to simply ignore it.

Create a cookie consent card anchored to the bottom-left corner, roughly 360px wide, with a cookie icon, a two-line explanation, a policy link and stacked Accept all and Reject all buttons of matching width and contrast. It must not overlap other fixed UI, so offset it above any support launcher. Do not include a bare X dismiss control — a close button that leaves consent unrecorded means the banner returns on every navigation. Render it after the main landmark in the DOM, keep it out of any focus trap, and persist the decision in a versioned localStorage entry with a timestamp so it stays hidden once answered.

在 MeDo 中尝试
Persistent accessReopen

Banner With a Preferences Trigger

The banner plus a permanent footer link that reopens it. Consent that cannot be changed later is the most common defect in a shipped banner, and the fix is one link.

Create a cookie consent bar plus a persistent Cookie preferences button for the site footer that reopens the same panel with the stored values pre-loaded, so a visitor can withdraw consent as easily as they gave it. The panel lists Necessary, Functional, Analytics and Marketing switches with non-essential ones reflecting whatever was saved, and offers Accept all, Reject all and Save preferences. On reopen, move focus to the panel heading and return focus to the footer button on close. Write changes to the same versioned localStorage key with a fresh timestamp and emit a consent-changed event so already-loaded tags can be told to stop.

在 MeDo 中尝试
Geo-awareRegional

Region-Conditional Consent Banner

Shows the full category panel where prior consent is expected and a lighter notice elsewhere, driven by a server-supplied region hint. The requirements vary by jurisdiction, so confirm the rules for each region with counsel.

Create a consent component that takes a region prop resolved server-side from the request and renders one of two variants: a full category panel with all non-essential switches defaulting to off and Accept all, Reject all and Save preferences of equal weight, or a lighter notice with an acknowledge action and a link to a cookie settings page. Never pre-tick a non-essential category in either variant. Store the decision with the region and a schema version so the record explains which variant produced it, and re-prompt when the version changes. Keep the region check server-side so no tracking script loads before the variant is known.

在 MeDo 中尝试

如何自定义你的 Cookie横幅

匹配您的网站设计系统

在提示词中指定品牌颜色、圆角和字体,使横幅看起来像原生组件 — 而非第三方插件。用户更愿意与看起来属于网站的横幅互动。

选择横幅位置和动画

底部栏、居中弹窗和角落吐司是三种主要模式。告诉MeDo您的偏好以及您想要上滑、淡入还是即时出现。底部栏最不打扰;弹窗对严格法域最合规。

调整按钮层级

暗模式(隐藏拒绝按钮)会引来监管罚款。要求MeDo给"接受"和"拒绝"同等的视觉权重,或使用中立的"管理偏好设置"CTA引导到细粒度同意弹窗。

添加偏好设置面板

为了更完善的合规性,要求MeDo包含一个可切换的偏好设置面板,带有分类开关(分析、营销、功能性)。这是GDPR合规和用户信任的黄金标准。

谁在使用 Cookie横幅 组件

SaaS产品

带有接受/拒绝和Cookie政策链接的轻量底部横幅。不打扰但合规 — 在满足GDPR义务的同时保持应用界面为焦点。

电商店铺

带有偏好设置弹窗的完整同意横幅,覆盖分析、个性化和营销Cookie。对使用广告像素和再营销的店铺至关重要。

营销或博客网站

带有单个"接受"按钮和Cookie设置文本链接的简单Cookie通知。为仅有分析Cookie的内容优先网站提供最小摩擦。

企业或受监管行业

带有供应商级别开关、完整的同意决策审计日志和突出"全部拒绝"选项的细粒度同意弹窗 — 为满足严格的DPA要求而构建。

不同网站的 Cookie横幅 方案

同一个 cookie横幅 组件,针对它所在网站的类型做调整。

01 / 06

SaaS Product Consent

A bottom bar with equal-weight accept and reject, and the reject path wired to skip product analytics rather than just hiding the bar. The failure here is a banner on the marketing site and none inside the authenticated app, where most of the event tracking actually happens.

Cookie横幅 的风格与变体

挑选与页面其余部分匹配的变体,然后生成它。

01 / 06

Bottom Bar Banner

Full-width strip pinned to the bottom, one line of copy, two buttons. The least disruptive pattern and the safest default. Watch the mobile height — a three-line bar covering a sticky Add to cart button is a conversion bug, not a design detail.

在 React、Next.js、Vue 与 Svelte 中使用 Cookie横幅

React、Next.js、Vue 3、SvelteKit、Astro 或纯 HTML —— 同一个 cookie横幅,六种接入方式。

01 / 06

React Cookie Banner

Consent belongs in a context provider at the app root, not in the banner — the banner is one reader of that state and every gated feature is another. Read localStorage in an effect so the first render matches the server.

src/components/ConsentProvider.tsx

const KEY = 'consent.v2'

export function ConsentProvider({ children }) {
  const [consent, setConsent] = useState(null)

  useEffect(() => {
    setConsent(JSON.parse(localStorage.getItem(KEY) ?? 'null'))
  }, [])

  return (
    <Ctx.Provider value={{ consent, setConsent }}>{children}</Ctx.Provider>
  )
}

如何把 Cookie横幅 加入项目

四个步骤,从挑选 cookie横幅 模板到上线生产环境。

01~30s

Pick a Consent Pattern

Choose by how many distinct cookie purposes you actually have — a bottom bar for one analytics script, a category panel once marketing and functional tags are separate concerns.

02~10s

Copy the Prompt

Paste it into MeDo, Lovable, Bolt, v0 or Cursor. Replace the category descriptions with the tags you really run, since that list is what your policy page has to agree with.

03~1min

Generate and Refine

You get React + Tailwind with a live preview. Follow up in plain English — "give reject all the same weight as accept", "expand preferences in place", "add a footer trigger that reopens it".

04~2min

Gate Your Scripts and Verify

Wire analytics and pixel loading to the stored value, then load the site fresh and confirm no non-essential request fires before a choice. Specific consent obligations vary by jurisdiction — have counsel review what you ship.

关于 Cookie横幅 的常见问题

如何用AI创建Cookie横幅?

在MeDo中,描述您需要的Cookie同意横幅 — 位置、按钮标签、使用的Cookie和视觉风格。MeDo生成完整的组件代码,您可以复制到项目中或通过后续提示词继续完善。无需搜索模板。

最好的AI Cookie横幅生成器是什么?

MeDo专为生成生产就绪的网站组件而构建,包括Cookie横幅。与通用AI工具不同,MeDo输出具有无障碍标记和合理GDPR合规标签默认值的干净语义代码 — 而非需要修复的粗糙模板。

AI能生成符合GDPR的Cookie横幅吗?

MeDo能生成遵循GDPR最佳实践模式的Cookie横幅:同等权重的接受/拒绝按钮、Cookie政策链接和可选的分类同意开关。但真正的法律合规取决于您的具体数据实践和管辖权 — 请务必让法务团队审核最终实现。

如何在Cookie横幅中添加"全部拒绝"按钮?

只需在提示词中包含它 — 例如,"添加一个与接受按钮同等视觉权重的全部拒绝按钮"。MeDo将生成具有匹配样式的两个按钮,并连接适当的逻辑占位符。

能用AI生成Cookie偏好设置弹窗吗?

可以。要求MeDo包含带有分类开关的偏好设置面板(如分析、营销、功能性Cookie)。MeDo将生成带有切换开关、分类描述和保存/确认操作的完整弹窗。

AI Cookie横幅能配合Google Analytics和Meta Pixel使用吗?

MeDo生成UI和同意门控逻辑。您可以要求它包含根据用户同意阻止或加载分析脚本的占位符钩子。将其连接到您特定的标签管理器或分析SDK需要生成后的一个小集成步骤。