const agreementCheckbox = new CheckBox({ id: 'terms_agreement', text: 'I agree to the terms and conditions', required: true });
root
innerContainer
checkboxFlexContainer
checkbox
checkboxLabel
errorMessage
true // when checked false // when unchecked
customValidation
value
checkboxQuestion.setResponse(true);
isValid
const { isValid, errorMessage } = checkboxQuestion.validate();
const newsletterSubscription = new CheckBox({ id: 'newsletter_signup', text: 'Subscribe to our newsletter', required: false, customValidation: (response) => { // Custom validation logic here return true; // or return an error message string }, styles: { root: { backgroundColor: '#f0f8ff', padding: '15px', borderRadius: '8px', boxShadow: '0 2px 4px rgba(0,0,0,0.1)' }, checkboxFlexContainer: { display: 'flex', alignItems: 'center', justifyContent: 'flex-start', gap: '10px', }, checkboxLabel: { color: '#2c3e50', fontSize: '1.2em', fontWeight: 'normal', }, checkbox: { width: '20px', height: '20px', accentColor: '#3498db' }, errorMessage: { color: '#e74c3c', fontWeight: 'bold', marginTop: '5px' } } });