shadcn.io is not affiliated with official shadcn/ui
Privacy Settings Block for React
A privacy panel with three presets that set five switches, a sentence that adds them up, and a row per setting that says in words what it means for you and what it shares.
Installation
Overview
Let people see what a privacy switch does before they flip it, with this privacy settings panel for React with Base UI. A Toggle Group offers three presets (Strict, Balanced, Open) that set all five switches at once; touching any switch leaves every preset unpressed and the line under the group reads Custom. Under it one sentence adds the five switches up ("Cloister sees screen names and crash reports. Partners see nothing. Your profile is private."), and it is rewritten with every change. Below are five rows (product analytics, personalised tips, usage shared with partners, crash reports, public profile), each leading with what is true right now, in words that change with its Switch, then one line saying what is shared and with whom. The action foot counts the changes and holds a Shine Button and a Discard Button. It's built from Toggle Group, Switch, Button, Shine Button and Guides, with a CSS entrance only. For a journaling app, a health tracker, a social product or any account with data sharing choices.
FAQ
How do I add a setting or change a preset?
Add an entry to SETTINGS with its name, the sentence for each state, who gets the data (product, partners or public), what is shared and a short clause for the summary sentence, then add a key to Flags and a value in each preset in PRESETS. The rows, the summary and the preset detection all read from those lists, so nothing else needs editing. A preset is just a full set of values: the active one is whichever preset matches every switch.
How does it fall to Custom?
After every change the page checks whether the five switches match any preset exactly. If one does, that preset shows as pressed; if none does, the group is left empty and the line says Custom with how many switches are on. Pressing a preset that is already in force does nothing. Setting the switches by hand to match a preset's values selects that preset again.
What stays local, and how do I make it real?
Everything. Save keeps the switches as the saved state in this page only (a reload brings back the starting values), and nothing is stored or shared. To make it real, send the five values to your server when the form is submitted, read them back on load, and make each flag gate the data it names: no analytics events, no partner export or public profile route while it is off.
Why does each row repeat what the switch does?
A bare switch labelled analytics tells people nothing about what changes, so each row states its consequence in a sentence that follows the state, and the line under it names who receives what: "Shared with partners: monthly totals, no name" or "Shared with partners: nothing". The sentence is wired to the switch as its description, so a screen reader hears it along with the switch's name. Keep these sentences true: they are the setting.
What do Save and Discard do?
They are always there and always answer. Save counts what changed since the last save and keeps it ("Saved 2 changes in this demo."); with nothing changed it says "No changes to save." Discard puts the last saved values back. The status line is a polite live region present from the start, and an edit is announced there ("Crash reports off.") until it is saved or discarded.
How does it look on a phone, and by keyboard?
The presets stay in one row, each row keeps its switch at the end and the sentences wrap, and the Save and Discard foot stays pinned to the bottom of the screen while the panel scrolls under it. By keyboard the presets are one group you move through with the arrow keys and press with Space or Enter, and each switch takes Space.
Related
- 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
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
Security Checkup Settings
Sign-in and securityA workspace security checkup page with a score and meter, eight checks that each say Pass or Needs attention with a reason and a button that flips them, and one primary button that moves focus to the first failing check.
- Pro
Data Export Settings
Backups and exportsA data export panel built around a tree of what an account holds, where ticking a part adds what it depends on and says so, with a format control, the size, time and file count it adds up to, and a request list that queues one archive at a time.
- 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
Compliance Controls Settings
Privacy and consentA policy review window: a rail of six sample policies grouped Overdue, Due soon and Current, and a pane with owner, cadence, the next review worked out from a typed date and who has acknowledged.