Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Cookie Consent Multi-Action Banner Block for React

A cookie prompt for an online shop: one split card with a stack of three equal-width choices, Accept all, Reject non-essential and Manage preferences.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A cookie prompt for React with Base UI, for a visitor who should be able to say no as easily as yes. Boltstead's card sits between the page's solid rails and is split by a solid divider: at the start a cookie icon, a heading and two sentences about what each kind of cookie does, and at the end a stack of three choices of the same width and height: a Shine Button "Accept all", an outline "Reject non-essential" and a ghost link "Manage preferences". Accepting or rejecting folds the whole block away with a CSS height transition and a polite line says what was saved. It is a labelled region with real buttons, never a dialog, so nothing is trapped. It's built from Guides and Button with your theme's tokens for every colour. For online shops, publishers and any site that needs a one-step cookie decision with a way into the details.

FAQ

Is this a dialog? Can it be pinned to the screen?

It is not a dialog: it is a section named by its heading, in the flow of the page, and it never traps focus. To pin it, put fixed inset-x-4 bottom-4 z-50 on the card's outer element (the one with max-w-2xl) and remove the py-8 md:py-12 padding on the wrapper above it; add pb-[env(safe-area-inset-bottom)] where phones have a home bar. Pinned or not, people can tab past it and keep reading.

Are the choices really equal?

Accept all and Reject non-essential are the same size and width and sit next to each other, and Reject is one press like Accept. The difference is colour: Accept is the Shine Button. If your regulator reads colour as weight, make both outline buttons and drop the Shine Button, so neither choice stands out.

What does Manage preferences do?

It is a link, not a button, because it leaves the prompt: point its href at your preferences page, or at the granular consent card (banner-multi-action-consent-granular) on a page of its own. It doesn't fold the prompt, so a visitor who changes their mind still has the choices in front of them when they come back.

Where is the choice stored?

Nowhere in this block: it forgets on purpose so the preview always shows it. In the two handlers, acceptAll and reject, write a first-party cookie such as boltstead-cookies=all or necessary, notify your tag manager, and have the server skip the card when the cookie exists. Reading storage after the first paint would show the card and then fold it away, moving the page.

Where does keyboard focus go after a choice?

The buttons can't keep focus once the card is folded and inert, so focus moves to a visually hidden line at the same spot that says "Cookie preferences saved: all cookies allowed." or "…only necessary cookies allowed.", which screen readers read. The next Tab carries on from there.

How does it fit on a phone?

The two parts stack under a rule: the text first, then the three buttons at full width, one per row. At 320 pixels nothing scrolls sideways, and in a right-to-left layout the divider and the order of the parts mirror.

  • Pro

    A consent card for a publisher site: four categories as a 2 by 2 of switch cells on shared hairlines, Essential locked on, with a Shine Button Save choices and an outline Accept all.

  • Pro

    An acknowledge-once callout for a newsletter platform: a card in card with an info icon, a heading, one sentence and a footer whose checkbox rewrites the outline button from Got it to Dismiss permanently.

  • Pro

    A region callout for a storefront: two cells split by a divider, a map pin and a live line at the start, and a US, EU and UK segment control at the end that rewrites the currency, tax and delivery line.

  • Pro

    A reading-preferences prompt for a reading app: three toggles with a live preview that changes size, weight and border, a polite count, and Save, Reset and Not now.

  • Pro

    A saved-settings toast pill for a settings panel: a success check, a message, an Undo button wearing a ring that drains over six seconds, and a dismiss button.

  • Pro

    A top bar for a developer tool whose long message stops at an ellipsis, with a More button that opens the whole text and a ghost close that folds the strip away.