Components
Consent Solution
A customizable cookie consent solution for web applications
Loading...
Features
- 🎯 All-in-one consent management - just listen to the consent hooks for your business logic
- 🌍 Out-of-the-box support for global privacy regulations (GDPR, CCPA, LGPD, US State Privacy)
- ⚡ Intelligent geolocation-based compliance handling
- 🔒 Flexible integration options:
- Use our complete consent management system
- Or bring your own consent logic with our raw components
- 🎨 Fully customizable:
- Built with Tailwind CSS and shadcn/ui
- Themeable to match your brand
- Responsive by default
- 📝 Comprehensive tooling:
- Automated consent persistence
- Server and client components
Legal Background
Before implementing cookie consent, it's important to understand the key legal requirements:
GDPR Requirements
- Explicit, granular consent must be obtained before processing any non-essential cookies
- Users must be able to withdraw consent as easily as they gave it
- Consent must be freely given, specific, informed, and unambiguous
- Pre-ticked boxes or implicit consent are not valid
CCPA/CPRA Requirements
- Users must be able to opt-out of the sale or sharing of their personal information
- A "Do Not Sell My Personal Information" link must be prominently displayed
- Businesses must honor Global Privacy Control (GPC) signals
- Users must be informed about the categories of personal information collected
LGPD Requirements
- Explicit consent must be obtained for data processing activities
- Users must be informed about the purpose of data collection
- Consent must be specific to each processing purpose
- Users must have easy access to their privacy rights
Installation
There are two ways to install the component:
Usage
Basic Usage
The simplest implementation with only necessary cookies:
Event Callbacks
Track user interactions with the consent system:
API Reference
ConsentManagerProvider
Prop | Type | Default |
---|---|---|
initialGdprTypes | allConsentNames[] | ["necessary"] |
initialComplianceSettings | Record<ComplianceRegion, ComplianceSettings> | - |
initialPrivacyPolicyUrl | string | - |
initialCookiePolicyUrl | string | - |
CookiePopup
Prop | Type | Default |
---|---|---|
bannerDescription | string | - |
bannerTitle | string | - |
className | string | - |
horizontalPosition | 'left' | 'center' | 'right' | center |
verticalPosition | 'top' | 'center' | 'bottom' | bottom |
enableScrollLock | boolean | false |
PrivacyConsentDialog
Prop | Type | Default |
---|---|---|
children | React.ReactNode | - |
className | string | - |
ConsentCustomizationWidget
Prop | Type | Default |
---|---|---|
onSave | () => void | - |
className | string | - |
useConsentManager
A hook for accessing the privacy consent context.
Prop | Type | Default |
---|---|---|
consents | ConsentState | - |
setConsent | (name: allConsentNames, value: boolean) => void | - |
saveConsents | () => void | - |
resetConsents | () => void | - |
setCallback | (name: keyof Callbacks, callback: CallbackFunction) => void | - |
setShowPopup | (show: boolean) => void | - |
setIsPrivacyDialogOpen | (open: boolean) => void | - |
Accessibility
The cookie consent components are built with accessibility in mind:
- Full keyboard navigation support
- ARIA labels and roles
- Focus management
- Screen reader announcements for consent changes
- High contrast mode support
Best Practices
- Always include necessary cookies as required
- Provide clear descriptions for each consent type
- Include links to privacy and cookie policies
- Implement proper consent persistence
- Handle consent changes appropriately
- Consider regional privacy regulations
- Use appropriate callbacks to track user interactions
- Provide multiple ways to access privacy settings
- Ensure consistent styling across components