
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
react-cookie-consent-notification
Advanced tools
The package will help you display a notification of consent to the use of cookies on the site
You need to install package:
npm install react-cookie-consent-notification
You can use yarn:
yarn add react-cookie-consent-notification
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>
Parameter | Type | Description | Default |
---|---|---|---|
background | string | Sets the notification background color in any format that supports css | #fff |
bottomPosition | boolean | By default notification is displayed at the top of the page. If set to true , the notification will be displayed at the bottom | false |
buttonText | string | Sets the button text | I agree |
buttonBackground | string | Sets the button background color in any format that supports css | #fff |
buttonColor | string | Sets the button text color | #000 |
buttonFontSize | string | Sets the button font size | 16 |
color | string | Sets the text color | #000 |
consentFunction | function | Sets function to track the status of consent | () => {} |
padding | number | Sets padding for consent cookie notification | 20 |
You can also add custom styles by passing the className
parameter:
<CookieConsent className={styles.CookieConsent} buttonClassName={styles.btn}>Your content</CookieConsent>
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;
Please read through our CONTRIBUTING.md.
FAQs
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.