shadcn.io is not affiliated with official shadcn/ui
Consent Manager Account Block for React
A person's consent choices as an accordion of purposes with switches beside a consent receipt, an ordered log that gains a line for each choice and saves as a real PDF or JSON file.
Installation
Overview
Let people see what they agreed to and when, with this consent manager for React with Base UI. A hairline frame with a plus mark on each corner splits in two. At the start four purposes (Essential, Analytics, Marketing, Personalisation) are an Accordion, one open at a time, each row saying what it is for and how many of its three Switches are on; Essential's three say "Always on" with the reason in words. At the end the consent receipt is an ordered log of what the person chose, newest first, each line with its instant, the policy version and where the choice was made. Every switch turned here adds a line marked This session, and the switches are worked out from the log, so the two can never disagree. The foot's Shine Button saves the receipt as a real PDF and a second button as a JSON file, both made from the same typed log. On a phone the receipt sits under the accordion. It's built from Accordion, Switch, Badge, Download Trigger, Shine Button, Button and Guides, with a CSS entrance only. For the privacy settings of a newsletter, a publisher or any product that has to keep proof of consent.
FAQ
How do I load a real receipt?
Edit HISTORY, the receipt as it stood when the page opened, newest first. Each line has an ISO at, a choice (on or off), the item it concerns (or an empty item with a note for a policy notice), the policy version and where it was made. The switches start from replaying that log, oldest first, so you never type the current state twice. ITEMS and PURPOSES hold the switches and their groups, three per purpose here so every panel is the same height.
What stays local, and how do I make consent real?
The choices and the receipt lines: a switch adds a line to this page's log and says "in this demo", and nothing reaches Alderpath. To make it real, send each change to your consent service from setChoice, add the line only when it answers with the server's own instant and receipt id, and keep the log append-only on the server: a receipt that can be edited proves nothing. The two files are real, made in the browser from the log; the sample subscriber id and receipt number are made up.
What is in the files?
The PDF is a plain one-page-per-42-lines document in ASCII: the receipt number, the policy version, the pseudonymous subscriber id, every choice as it stands and then the history newest first. The JSON holds the same facts as data: choices, history, lastChange, policy, receipt and subject. Saving after a switch includes that switch's new line, and the status line says how many entries went in. Nothing is uploaded.
Why is there no Undo?
Because a consent receipt is a record, not a draft. Turning a switch back off is a choice of its own and gets its own line, with its own instant, so the log shows both and the person can prove when each was made. Withdrawing is one switch, the same effort as agreeing.
How does the accordion behave?
One purpose is open at a time and one always stays open, so the panel never changes height. Each purpose's count ("2 of 3 on") follows its switches, and the header counts the optional ones ("3 of 9 optional on"). Tab moves between the purpose headers; arrow keys are not wired between them.
Is it accessible?
Each switch is named for its purpose and item ("Analytics: Link clicks"), the receipt is a named, focusable scroll region holding a real ordered list, and a choice is a word with an icon ("On", "Off"), never a color. The status line is a polite live region present from the start. Instants keep their order in a right-to-left page. On a phone the foot with the status line and the two save buttons stays pinned to the bottom of the screen.
Related
- Pro
GDPR Consent Settings
Privacy and consentA purposes register with a legal basis, retention and consent record per purpose, a rule that withdrawing must be as easy as giving, and three data requests counted down from 30 days.
- Pro
Cookie Consent Settings
Privacy and consentA cookie preferences page with four purpose cells on shared hairlines: necessary locked on in words, three switches, and under each the exact cookies it covers, kept for how long, set or blocked.
- Pro
A person's record of who their data went to: a row per recipient with the kinds of data it received, the day it last did and why, and a switch that stops the sharing where consent is the reason.
- Pro
The cookies on a person's own browser as a table of eleven typed cookies with name, provider, purpose and dates, four category switches that clear what they cover, a search and a delete that asks first.
- Pro
The people a person has blocked or muted, as two tabs of rows with initials, handle and date, an Unblock or Unmute that can be undone, and a handle field that adds someone from four typed accounts.
- Pro
Cookie Settings Dialog
Confirm and consentA newspaper's cookie preference centre shown open over its front page: four categories with switches and counts, Essential locked on, and for the chosen one a sentence and a table of its actual cookies, then Reject non-essential, Accept all and Save choices.