README
react-cookienotice
A lightweight & customizable cookie banner for your React App
- ๐ No dependency, full self-made package (1.3 kB - BundlePhobia)
- ๐ฑ Mobile first & responsive
- โ๏ธ Customizable with several props
- ๐ Very fast setup (less than 1 minute)
- ๐งช Tested with functionals tests
- ๐ Dark mode based on system settings
- ๐ Translated in French & English (create issue for more languages)
Install
Yarn
yarn add react-cookienotice
npm
npm i --save react-cookienotice
Usage
import React from 'react'
import CookieNotice from 'react-cookienotice'
import 'react-cookienotice/dist/index.css'
const Example = () => <CookieNotice />
export default Example
Props
All props are optionals
Key | Type | Description | Default value |
---|---|---|---|
acceptButtonLabel | string |
Edit the "Accept" button label | Accept |
readMoreButtonLabel | string |
Edit the "Read more" button label | Read more |
readMoreButtonLink | string |
Edit the "Read more" button link | http://aboutcookies.org/ |
readMoreButtonOpenInNewTab | boolean |
Open the "Read more" button link in a new tab | true |
cookieTextLabel | string |
Main cookie notice label | This website uses cookies to improve your browsing experience. |
cookieExpiration | number |
Days after cookie expires and user should reaccept cookies | 30 |
cookieName | string |
The name of the cookie that saves the user consent | allow-cookies |
onAcceptButtonClick | Function |
A callback function called after the "Accept" button click | - |
License
MIT ยฉ xavierbriole