shadcn.io is not affiliated with official shadcn/ui
Cookie Consent Footer Block for React
A footer for a writing app whose legal row opens a cookie settings dialog with a switch per category and shows what was saved.
Installation
Overview
A footer with a persistent way back to the reader's cookie choices for React with Base UI. A brand band, four groups of links (a nav labelled Footer) in columns divided by hairlines, and a legal row with the copyright and the policies at the start and a ghost "Cookie settings" button at the end. The button opens a dialog with one switch per category, Essential (locked on), Analytics and Marketing, a Shine Button "Save choices" and an outline "Reject all". Saving closes the dialog, returns focus to the button and writes the result in the legal row, "Analytics on, Marketing off", beside a status dot, and in a polite live line. It is an entry point, not a banner: the reader opens the dialog, so it may hold focus while it is open, and nothing appears on load. The rails and top rule come from the Guides spine, and the legal row's rule is drawn by Guides, with none under it because a footer ends the page.
FAQ
How do I add a category or change the wording?
Add an entry to CATEGORIES at the top of the file (an id, a title and a description) and a matching key to the Choices type and OFF. Each entry draws one switch row, and the summary in the legal row is built by summary, so extend it with the new name. Essential is written out separately because it can't be turned off.
Where is the choice saved?
Nowhere yet: it lives in the block's state, so a reload starts from "no choice". In save and reject, write the result to the cookie or storage your consent logic reads and load your analytics and marketing scripts only when it says so; start saved from that value so the legal row shows it on load.
Does the dialog trap focus?
Yes, while it is open: it is a modal dialog the reader opened, so Tab stays inside it, Escape closes it and focus returns to the "Cookie settings" button. Nothing opens on load and nothing blocks the page until the button is pressed, which is why this is not a consent banner and takes none of the care a banner would need.
How are the switches named?
Each switch is named by its row's title and described by the sentence under it, so a screen reader reads "Analytics, switch, off, counts which pages are read…". Essential is a switch that is on and disabled, with "Always on" in its description, so it is clear why it can't be changed. Checked switches are foreground-coloured, so the Shine Button stays the one primary control.
Related
- Pro
Cookie Consent Multi-Action Banner
Choices and promptsA 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
Granular Consent Multi-Action Banner
Choices and promptsA 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
Legal Strip Footer
Slim and minimalA legal-only footer: a strip of five legal links as cells on shared hairlines, and a band with the wordmark and the legal entity line.
- Pro
Link Columns Footer
Link gridsThe classic link-column footer for an email API: a brand column with the wordmark, one sentence and four social links, four groups of links behind a split divider, and a legal band with the copyright and the policy links.
- Pro
Language Selector Footer
PreferencesA footer for a meeting-notes tool whose segmented control (EN, FR, DE, ES) rewrites the footer's own words, with three link groups and a legal row.
- Pro
Payment Method Billing
Payment and invoicesPayment methods in app settings: the card on file with an expiry warning, a backup bank account, a button that sets the default, and a dialog that checks and updates the card.