Checkbox

Introduction

Name: didomi-checkbox Component type: checkbox Extends: DidomiBlock

Display a single checkbox.

window.didomiConfig = {
...
entities: [...],
components: {
layout: {...},
activeComponents: [
{
id: "ID_OF_THE_COMPONENT",
type: "checkbox",
options: {
...,
propKey: "PROP_VALUE" // Remember to use camelCase for the key
}
}
]
}
};

Inline configuration

<didomi-checkbox container-id="CONTAINER_ID" prop-key="PROP_VALUE" .../>

Setup‌

For this component to work properly, you will need to have entities (purposes, preferences and channels) available to link to the checkbox.

A checkbox is linked to an entity and its parents, if any. The current entity will be displayed in the checkbox (name, status). If you want to display a preference, your current entity is the preference. You will have to populate the purposeId and the preferenceId .

window.didomiConfig = {
...
entities: {
layout: {
purposes: [
{
id: "purpose-id",
preferences: [
{
id: "preference-id",
channels: [] // Don't forget this property, even if you have no channels linked to it
}
]
}
]
},
activeEntities: [
{
id: "purpose-id",
name: "...",
description: "..."
},
{
id: "preference-id",
name: "Preference 1"
}
]
},
components: {
layout: {...},
activeComponents: [
{
id: "ID_OF_THE_COMPONENT",
type: "checkbox",
options: {
...,
purposeId: "purpose-id",
preferenceId: "preference-id"
}
}
]
}
};

Props Options

Name

Type

Description

activeIcon

DidomiImage

Icon of the checkbox when it is checked

activeLabel

DidomiElement

Label of the checkbox when it is checked

activeText

DidomiText

Override the name of the entity linked to the checkbox when it is checked

channelId

String

ID of the channel linked to the checkbox.

color

String

Color of the checkbox

display

String

CSS display property. Example: 'flex', 'inline' ...

enabledPath

String

If you want to save the consent status in a different path in the metadata object of the current entity, you can set a different path as a string. For example if you want to save the consent in a brands object located in the entity metadata, for the brand didomi, in an attribute called enabled, you would add brands.didomi.enabled

fontSize

String

Font size of the text

hasBorder

Boolean

Does the checkbox have a border

icon

DidomiImage

Allow to add an icon inside the checkbox

indicator

DidomiBlock

Container of the indicator

isShown

Boolean

display/hide the element (default true)

label

DidomiElement

Label of the checkbox

metadata

Object

Metadata passed to the HTTP request. See this section for more information

padding

String

padding of the checkbox

preferenceId

String

ID of the preference linked to the checkbox.

purposeId

String

ID of the purpose linked to the checkbox.

saveOnClick

Boolean

Should the consent be saved on click or set as pending consent. This attribute gives you the choice to either save the consent immediately or wait and save all the pending consents together with a didomi-save component for example. Default value: false.

text

DidomiText

Override the name of the entity linked to the checkbox

textColor

String

Color of the text

For inline configuration, make sure to use kebab-case syntax. For example purposeId will become purpose-id.

Metadata

If you enabled save-on-click and you want to send additional information to the POST HTTP request, you can populate this attribute with data. It will be sent beside the consent object in the body request as a metadata object.

window.didomiConfig = {
...
components: {
activeComponents: [
{
id: "checkbox-email",
type: "checkbox",
options: {
...
metadata: {
brand: "didomi",
value: "test"
}
}
}
]
}
};

Examples

If you want to see the image, please click on the Open preview in new window button to see the example on full screen.

Object configuration

window.didomiConfig = {
...
entities: [...],
components: {
layout: {...},
activeComponents: [
{
id: "checkbox-email",
type: "checkbox",
options: {
purposeId: "purpose-id",
preferenceId: "preference-id",
channelId: "channel-id-email",
color: "#F07D5A"
}
},
{
id: "checkbox-print",
type: "checkbox",
options: {
purposeId: "purpose-id",
preferenceId: "preference-id",
channelId: "channel-id-print",
color: "#003790",
padding: "10px",
hasBorder: true
}
},
{
id: "checkbox-text",
type: "checkbox",
options: {
purposeId: "purpose-id",
preferenceId: "preference-id",
channelId: "channel-id-text",
color: "#F07D5A",
fontSize: "20px"
}
},
{
id: "checkbox-call",
type: "checkbox",
options: {
purposeId: "purpose-id",
preferenceId: "preference-id",
channelId: "channel-id-call",
color: "#F07D5A",
textColor: "#003790"
}
}
]
}
};