跳到主要内容

ICheckbox

Custom checkbox.

checkboxcheckbox

Example​

Privacy policy checkbox with submit button state control

const privacyCheckbox: ICheckbox = {
isChecked: false,
label: "I agree to the Privacy Policy",
onChange: () => {
return {
actions: [Actions.updateProps, Actions.updateContext],
newProps: {
isChecked: !privacyCheckbox.isChecked
},
contextProps: [{
name: "submitButton",
props: {
isDisabled: !privacyCheckbox.isChecked
}
}]
};
},
truncate: false,
tabIndex: 1,
hasError: false,
name: "privacy-policy",
value: "accepted",
isIndeterminate: false,
isDisabled: false,
title: "Privacy Policy Agreement"
}

Properties​

PropertyTypeDescription
isCheckedbooleanSets the checked state of the checkbox
labelstringDefines the checkbox label
onChange() => void | IMessageSets a function which is triggered whenever the checkbox input is clicked
truncatebooleanSpecifies if the word wrapping is disabled or not
tabIndexnumberDefines the checkbox tab index
hasErrorbooleanSpecifies whether a notification will be sent if an error occurs
namestringDefines the HTML "name" property
valuestringDefines the checkbox input value
isIndeterminatebooleanSpecifies whether the checkbox state will be displayed as a black rectangle in the checkbox when it is set to true
isDisabledbooleanSpecifies if the checkbox input is disabled
titlestringDefines the checkbox input title
classNamestringDefines the CSS class for styling the component. Can be used to override or extend the default component styles.