1

Can someone advise on how to use the ButtonComponent of react-cookie-consent library. I want to add a third button on top of the accept and decline one. Looking at their documentation, there is a button component which is described as follow: ButtonComponent |React component|button |React Component to render as a button.

I have tried to use it in different ways, as a component child of the CookieConsent component <ButtonComponent/> or as props `

<CookieConsent ButtonComponent="button"
     ButtonComponentStyle={
     color: "#ffff",
     background: "#245564",
     padding: "10px 20px",
     borderRadius: "16px",
     fontSize: "1em",
     display: "flex",
     alignContent: "center",
     }>
     </CookieConsent>

None of these worked.

Aniruddh Parihar
  • 3,072
  • 3
  • 21
  • 39
Leo
  • 481
  • 2
  • 9
  • 20

1 Answers1

1

Maybe too late but I think that the solution is to add "enableDeclineButton" and "declineButtonText="Decline" ". Like this:

    <CookieConsent
        location="bottom"
        buttonText="Accept"
        cookieName="cookieName"
        enableDeclineButton
        declineButtonText="Decline"
        declineCookieValue={false}
        style={{ background: "#2EB7EB" }}
        buttonStyle={{ background:"#f5f5f5", color: "black", fontSize:"13px"}}
        declineButtonStyle={{background:"#cfcfcf", color: "black", fontSize: "13px"}}
        expires={150}> 
    </CookieConsent>

  • thanks for this @angelwynn1511. It is never too late. I will use it in another project :) – Leo Jan 27 '23 at 07:54