Skip to main content

Cookie Banner

v.5.0.1

Installation

yarn add @mercell/cookie-banner-react

Usage

Using the Cookie Banner component is as simple as importing it like this.

import { CookieBanner } from '@mercell/cookie-banner-react';
Live Editor
Result

Types, definitions, etc.

CookieBanner
interface CookieBanner {
title: string;
description: string;
openDetailsLabel: string;
onSubmit: (details: { [key: string]: boolean }) => void;
acceptAllLabel: string;
cookies: Omit<CookieToggleProps, 'onChange' | 'checked'>[];
detailsHeader: string;
enableAllLabel: string;
detailsSaveLabel: string;
}
NameTypeDefaultRequiredDescription
titlestring-yesTitle in the menu
descriptionstring-yesDescription in the menu
openDetailsLabelstring-yesText for the label to open toggles and in-depth cookie information
onSubmitfunction-yesWhat happens when the user presses the accept button
acceptAllLabelstring-yesText for the button which accepts all the cookies
cookies-yesOmits the onchange from CookieToggleProps
detailsHeaderstring-yesHeader for the details
enableAllLabelstring-yesText for the button that enables all cookies in detail view
detailsSaveLabelstring-yesSave button text in the preferences
CookieToggleProps
interface CookieToggleProps {
id: string;
header: string;
shortDescription: string;
description: string;
onLabel: string;
offLabel: string;
checked?: boolean;
onChange: JSX.IntrinsicElements['input']['onChange'];
}
NameTypeDefaultRequiredDescription
idstring-yesA unique identifier for the label and toggle inside the component to work together
headerstring-yesHeader of the toggle
shortDescriptionstring-yesShort description of the toggle
descriptionstring-yesDescription of the toggle
onLabelstring-yesThe label for when the toggle is toggled on
offLabelstring-yesThe label for when the toggle is toggled off
checkedboolean-noOptional toggle to check the toggle on render
onChangeJSX.IntrinsicElements['input']['onchange']-noonChange method for toggle