To install the package, run the following command:
npx shadcn@latest add http://shadcn-cookies.vercel.app/r/cookie-consent.json
The CookieConsent
component provides a simple way to handle cookie consent in your application. It supports multiple variants (default
, small
, minimal
) and allows you to execute custom functions when users accept or decline cookies.
import { CookieConsent } from "@/components/ui/cookie-consent"
export default function Page() {
return (
<CookieConsent
variant="default"
onAcceptCallback={() => {
// Handle accept
}}
onDeclineCallback={() => {
// Handle decline
}}
/>
)
}
import { CookieConsent } from "@/components/ui/cookie-consent"
export default function Page() {
return (
<CookieConsent
variant="small"
onAcceptCallback={() => {
// Handle accept
}}
onDeclineCallback={() => {
// Handle decline
}}
/>
)
}
import { CookieConsent } from "@/components/ui/cookie-consent"
export default function Page() {
return (
<CookieConsent
variant="minimal"
onAcceptCallback={() => {
// Handle accept
}}
onDeclineCallback={() => {
// Handle decline
}}
/>
)
}
We welcome contributions to improve shadcn/ui cookies
!
- Fork the Repository - Click the "Fork" button at the top right of this page.
- Clone Your Fork - Run the following command in your terminal:
git clone https://github.com/kaizenics/shadcn-cookies.git
cd shadcn-cookies
- Create a New Branch - Name it something relevant. e.g.,
feature-minimal-variant
orvariant-minimal-added
:
git checkout -b feature-minimal-variant
- Make Your Changes - Implement your improvements or fixes.
- Commit & Push
git add .
git commit -m "feat: added new cookie consent variant"
git push origin feature-minimal-variant
- Open a Pull Request - Go to original repo, click "New Pull Request", and select your branch.