Socket
Book a DemoInstallSign in
Socket

react-cookie-consent-notification

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cookie-consent-notification

The package will help you display a notification of consent to the use of cookies on the site

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

react-cookie-consent-notification

Version Build Coverage Minified size Downloads Dependabot PRs Welcome Tested with jest

Table of contents

Installation

You need to install package:

npm install react-cookie-consent-notification

You can use yarn:

yarn add react-cookie-consent-notification

Getting started

You should import the component:

import CookieConsent from 'react-cookie-consent-notification';

Then use the component in your application. You should call the component as follows:

<CookieConsent background={'#000'} color={'#fff'}>JSX custom content</CookieConsent>

The settings of the component

ParameterTypeDescriptionDefault
backgroundstringSets the notification background color in any format that supports css#fff
bottomPositionbooleanBy default notification is displayed at the top of the page. If set to true, the notification will be displayed at the bottomfalse
buttonTextstringSets the button textI agree
buttonBackgroundstringSets the button background color in any format that supports css#fff
buttonColorstringSets the button text color#000
buttonFontSizestringSets the button font size16
colorstringSets the text color#000
consentFunctionfunctionSets function to track the status of consent() => {}
paddingnumberSets padding for consent cookie notification20

Custom styles

You can also add custom styles by passing the className parameter:

<CookieConsent className={styles.CookieConsent} buttonClassName={styles.btn}>Your content</CookieConsent>

Example

import CookieConsent from 'react-cookie-consent-notification';

const checkStatus = (status) => {
  if(status) {
    // To set a cookies
  }
};

const App = () => (
  <div className="app">
    ...
    <CookieConsent 
      background={'#000'}
      bottomPosition={false}
      buttonText={'I agree'}
      buttonBackground={'#fff'}
      buttonColor={'#000'}
      buttonFontSize={16}
      color={'#fff'}
      consentFunction={checkStatus}
      padding={20}
    >
      This website uses cookies to improve service, for analytical and advertising purposes.
      Please read our <a href={'/cookies'} style={{ color: '#fff' }}>Cookie Policy</a>.
      Confirm your consent to the use of cookies.
    </CookieConsent>
  </div>
);
export default App;

Contributing

Please read through our CONTRIBUTING.md.

Keywords

react-component

FAQs

Package last updated on 19 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.