mui-next-cookie-consent 3.1.0
Install from the command line:
Learn more about npm packages
$ npm install @eisberg-labs/mui-next-cookie-consent@3.1.0
Install via package.json:
"@eisberg-labs/mui-next-cookie-consent": "3.1.0"
About this version
React Material Ui cookie consent dialog, compatible with Nextjs cookies.
Since this is an extension of mui components, prerequisite is to have material library already installed.
npm i --save @mui/material
npm i --save @eisberg-labs/mui-next-cookie-consent
Just import the template with defaults:
<CookieConsent>This website uses cookies to enhance the user experience.</CookieConsent>
I use it in a nextjs app like this:
const CookieConsent = dynamic(() => import('@eisberg-labs/mui-next-cookie-consent'), {suspense: true});
export default function Layout({ children }) {
return (
<>
<AppHeader />
<div className={styles.wrapper}>{children}</div>
<Suspense><CookieConsent
cookieOptions={{
expires: moment().add(1, 'years').toDate()
}}
confirmText="I agree"
>This website uses cookies to enhance the user experience.</CookieConsent></Suspense>
<Footer />
</>
);
}
You can change the default styling, cookie key, set expires, register callback on Accept.
Name | Type | Default | Description |
---|---|---|---|
defaultName | string | 'CookieConsent' | Cookie key name for cookie consent |
confirmText | React.ReactNode | 'I understand' | Confirm button text |
buttonVariant | 'text', 'outlined', 'contained' | 'text' | Button variant |
cookieOptions | CookieSerializeOptions | e.g. {expires: moment().add(1, 'days').toDate()}
|
|
onAccept | ()=>void | Optional function that triggers after cookie consent accepted. | |
sx | SxProps | Define styling of the cookie consent container | |
butttonSx | SxProps | Define styling of the button. |
MIT © Eisberg Labs
Details
- mui-next-cookie-consent
-
eisberg-labs
- over 2 years ago
- MIT
- 7 dependencies
Assets
- mui-next-cookie-consent-3.1.0.tgz
Download activity
- Total downloads 326
- Last 30 days 0
- Last week 0
- Today 0