Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Consent Check Alert Banner Block for React

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.

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

An acknowledge-once callout for React with Base UI, for a notice people should read once and then be able to silence. A muted shell with + marks on its corners holds a raised panel: an info icon, a short heading and one sentence about product updates moving to a monthly digest. Under a hairline, a footer puts a "Don't show this again" checkbox at the start and an outline button at the end. Ticking the box rewrites the button from "Got it" to "Dismiss permanently", and either word folds the whole block away with a CSS height transition. The status colour stays on the icon and on one hairline along the panel's top edge; the rest follows your theme. The page's rails and top rule come from the Guides spine. It's built from Guides, Checkbox, Label and Button, with your theme's tokens for every colour. For policy changes, beta terms, onboarding notices and any message that people should be able to turn off.

FAQ

Is this a dialog? Does it trap focus?

No. It is a section named by its heading, in the flow of the page, with real buttons and a checkbox, so nothing is trapped and nothing blocks the page behind it. Screen readers list it with the page's regions and people can jump past it. If your notice appears later, after a save or a sync, put role="status" on an element that is in the page from the start and fill its text when the notice arrives.

How does the checkbox rewrite the button?

The checked state lives in the block. Both words, "Got it" and "Dismiss permanently", sit in one grid cell inside the button and the unused one is invisible, so the button keeps one width and nothing around it moves when you tick the box. Screen readers hear only the visible word. The label wraps the box, so clicking the words toggles it too.

Does Dismiss permanently remember anything?

Not in this block: it forgets on purpose, so the preview always shows it. To remember, set a cookie named after the notice (notchspring-digest-notice) in the dismiss handler when the box is checked, and skip rendering the block when your server sees it. Reading a stored value after the first paint would show the card and then fold it, moving the page, so decide on the server.

Where does the keyboard go after it closes?

The button can't keep the focus once the card is folded and inert, so focus moves to a short visually hidden line at the same spot, "Digest notice dismissed.", which screen readers read out. The next Tab carries on from there.

Why is the button outline and not the Shine Button?

Acknowledging a notice is not the page's main action, so the button is an outline Button and the checked box is a foreground tone, not the primary colour. That leaves the primary for your hero's or pricing's one call to action.

How does it fit on a phone?

The icon and heading stay on one row with the sentence under the heading. The footer stacks: the checkbox first, then the button at the full width of the panel. At 320 pixels nothing scrolls sideways, and in a right-to-left layout everything mirrors.

  • Pro

    An in-page info callout for an invoicing app: a card in card with an info icon, a heading, two sentences about a change coming next month, a Shine Button link and a dismiss button that folds the block away.

  • Pro

    A setting callout for an uptime monitor: a card in card with a bell icon, a heading and a sentence, and an Off or On label beside a switch that rewrites the sentence and lights a status dot.

  • 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

    An expiry callout for a certificate manager: a framed panel with a warning icon and a Shine Button that renews in place, turning the alert into a success, plus a ghost button that folds it away.

  • Pro

    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.

  • 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.