Croissant Cart Opt-In Input
This component is a checkbox with all styling completely stripped. When checked, a request is made to the merchant-proxy-opt-in-url
to POST a true
isOptedIn
value to the passed in cart.
The component is intentionally completely visually hidden so that the styling can be completely customized by applying a custom CSS class.
Required Attributes
cart
cart
merchant-id
merchant-id
merchant-proxy-opt-in-url
merchant-proxy-opt-in-url
placement
placement
Optional Attributes
label
Type: String
The default is "Croissant Cart Opt-In Checkbox". This sets the checkbox input's aria-label
value.
There is no <label>
tag attributed to this component. If a <label>
is desired, it can be created externally and linked to the input via the input's name "croissant-cart-opt-in-input"
.
Example using label attribute:
<croissant-cart-opt-in-input label="Opt in to Croissant"></croissant-cart-opt-in-input>
Example using an external label
<croissant-cart-opt-in-input label=""></croissant-cart-opt-in-input>
<label for="croissant-opt-in-input">Opt in to Croissant for Guaranteed Buybacks.</label>
Customization
custom-checkbox-class
Type: String
The Opt-In Input is a checkbox with all styling completely stripped. The styling can be modified by hooking into the CSS class name:.croissant-cart-opt-in-input
.
Example Code:
<croissant-cart-opt-in-input></croissant-cart-opt-in-input>
// See CSS tab for example CSS
.croissant-opt-in-input input[type="checkbox"] {
appearance: none;
-webkit-appearance: none;
display: flex;
align-content: center;
justify-content: center;
font-size: 22px;
padding: 2px;
border: 2px solid violet;
border-radius: 50%;
cursor: pointer;
}
.croissant-opt-in-input input[type="checkbox"]::before {
content: "";
width: 12px;
height: 12px;
transform: scale(0);
background-color: rgb(168, 86, 168);
border-radius: 50%;
}
.croissant-opt-in-input input[type="checkbox"]:checked::before {
transform: scale(1);
}
.croissant-opt-in-input input[type="checkbox"]:hover {
color: black;
}
Screenshot
Selected:
Unselected:
Updated 5 months ago