beyonk-group / gdpr-cookie-consent-banner

A GDPR compliant cookie consent banner implementation
MIT License
248 stars 42 forks source link

How to change the background color of checked toggles? #57

Closed jvolker closed 10 months ago

jvolker commented 11 months ago

First of all, thanks for writing and sharing this component.

I'd like to change the background-color of only the checked toggles.

This works to turn all of them green, even the unchecked ones:

<style>

:global(.cookieConsentOperations__Item label::before) {
    background-color: green !important;
}

</style>
image

I've tried this to target only the checked ones using the following code:

<style>

:global(.cookieConsentOperations__Item label::part(operations--list-item-label--checked)::before) {
    background-color: green !important;
}

</style>

Unfortunately, with this, none of them turn green. How to do this correctly?

Thanks a lot in advance.

jvolker commented 10 months ago

I have found a solution:

<style>

    :global(.cookieConsentOperations__Item:not(.disabled) input:checked+label::before) {
        background-color: green;
    }

</style>
image