Learn about customisation options for the card CVC component.
const cardCvcConfig: CardCvcComponentConfig = {
applyMask: boolean,
showMaskToggle: boolean,
dynamicCardImageComponent: DynamicCardImageComponent,
showHintIcon: boolean,
showTooltip: boolean,
hintIconSrc: string,
maskButtonAriaLabel: string,
unmaskButtonAriaLabel: string,
inputAttributes: InputAttributes,
required: boolean,
placeholder: string,
componentStyles: ComponentStyles,
inputStyles: StateStyles,
label: string,
labelStyles: StateStyles,
isFloatingLabel: boolean,
labelPosition: string,
invalidTextStyles: CSSProperties,
invalidTextPosition: string,
guideText: string,
validations: T,
invalidIconSrc: string,
validIconSrc: string,
displayValidIcon: boolean,
displayInvalidIcon: boolean,
tooltipAriaLabel: string,
ariaLabel: string,
displayRequiredIcon: boolean,
allowToCopyPaste: boolean,
validationOnBlur: boolean,
validationOnChange: boolean,
tabIndex: number
};| Property | Description |
|---|---|
applyMaskboolean | Whether to mask the CVC input (e.g., *** or ****). |
showMaskToggleboolean | Whether to display a toggle to show/hide the CVC. |
dynamicCardImageComponentDynamicCardImageComponent | Component to display dynamic card images. See Dynamic card image. |
showHintIconboolean | Whether to display a hint icon next to the CVC field. |
showTooltipboolean | Whether to display a tooltip with the hint icon. |
hintIconSrcstring | The URL to your custom hint icon. |
maskButtonAriaLabelstring | The aria label for the mask button. |
unmaskButtonAriaLabelstring | The aria label for the unmask button. |
inputAttributesInputAttributes | Additional HTML input attributes. |
requiredboolean | Whether the field is required for submission. |
placeholderstring | The placeholder text to display when the field is empty. |
componentStylesComponentStyles | Custom styling for the component. |
componentStyles.baseCSSProperties | Base styling for the component. |
componentStyles.validCSSProperties | Styling for the component when it's valid. |
componentStyles.invalidCSSProperties | Styling for the component when it's not valid. |
componentStyles.inputCSSProperties | Styling for the input element. |
inputStylesStateStyles | Style for input field in various states. |
labelstring | The input label's text. |
labelStylesStateStyles | The label styling, based on the state. |
labelPositionstring (enum) | The position of the label, relative to the input field. Possible values:
|
invalidTextStylesCSSProperties | Style for validation message text. |
invalidTextPositionstring (enum) | The position of the invalid text message, relative to the input field. Possible values:
|
guideTextstring | The helper text to display below the input field. |
validationsT | Validation rules to be applied to the input field. |
invalidIconSrcstring | The URL for the icon shown on invalid input. |
validIconSrcstring | The URL for the icon shown on valid input. |
displayValidIconboolean | Whether to display a success icon. Defaults to true. |
displayInvalidIconboolean | Whether to display an error icon. Defaults to true. |
tooltipAriaLabelstring | The aria label for the tooltip. |
ariaLabelstring | The aria label for the field component. |
displayRequiredIconboolean | Whether to display a required icon. Defaults to true. |
allowToCopyPasteboolean | Whether to allow copy/paste in the input fields. |
validationOnBlurboolean | Whether to run validation when input loses focus. |
validationOnChangeboolean | Whether to run validation as a value changes. |
tabIndexnumber | The tab index of the input element. |
const cardCvcConfig: CardCvcComponentConfig = {
onChange: (event: InputEvent) => void,
onFocus: (event: FocusEvent) => void,
onBlur: (event: FocusEvent) => void,
onValidationPassed: (data: ValidationResult[]) => void,
onValidationFailed: (data: ValidationResult[]) => void
};| Callback | Description |
|---|---|
onChange: (event: InputEvent) => void | Event handler for when the input value changes. |
onFocus: (event: FocusEvent) => void | Event handler for when the input receives focus. |
onBlur: (event: FocusEvent) => void | Event handler for when the input loses focus. |
onValidationPassed: (data: ValidationResult[]) => void | Event handler for when all validations pass. |
onValidationFailed: (data: ValidationResult[]) => void | Event handler for when any validation fails. |
For more information about callbacks, see Events.
const cardCvcConfig: CardCvcComponentConfig = {
label: "CVC",
placeholder: "123",
required: true,
applyMask: true,
showMaskToggle: true,
showHintIcon: true,
showTooltip: true,
validationOnBlur: true,
inputStyles: {
base: {
border: "1px solid #ccc",
padding: "12px",
borderRadius: "4px",
fontSize: "16px"
},
valid: {
borderColor: "#28a745"
},
invalid: {
borderColor: "#dc3545"
}
},
labelStyles: {
base: {
fontWeight: "500",
marginBottom: "8px"
}
},
tabIndex: 3,
onChange: (event) => {
console.log("CVC changed");
},
onFocus: (event) => {
console.log("CVC focused");
},
onBlur: (event) => {
console.log("CVC blurred");
},
onValidationPassed: (data) => {
console.log("CVC valid");
},
onValidationFailed: (data) => {
console.log("CVC validation failed");
}
};