You can't set a background color for checked checkbox. Even !important
doesn't help.
You can workaround with JavaScript (toggle class on change event) or advanced CSS though.
With CSS, you can hide browser's default checkbox and replace it by a picture or "constructed" checkbox.
The following example is an adaption of the blog Creating Custom Form Checkboxes and Radio Buttons with Just CSS!
XPage
<xp:this.resources>
<xp:styleSheet href="/myCSS.css"></xp:styleSheet>
</xp:this.resources>
<xp:checkBox id="checkBox1" styleClass="checkbox" value="#{viewScope.test}"></xp:checkBox>
<xp:label id="label1" for="checkBox1"></xp:label>
<xp:label id="label2" for="checkBox1" value="Label"></xp:label>
myCSS.css
.checkbox {
display: none;
}
.checkbox + label {
background-color: #fafafa;
border: 1px solid #cacece;
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05);
padding: 9px;
border-radius: 3px;
display: inline-block;
position: relative;
}
.checkbox + label:active, .checkbox:checked + label:active {
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px 1px 3px rgba(0,0,0,0.1);
}
.checkbox:checked + label {
background-color: green;
border: 1px solid #adb8c0;
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05), inset 15px 10px -12px rgba(255,255,255,0.1);
color: #white;
}
.checkbox:checked + label:after {
content: '\2714';
font-size: 14px;
position: absolute;
top: 0px;
left: 3px;
color: white;
}