Skip to content

Cardholder name

Learn about customisation options for the cardholder name component.

Styling

const cardHolderNameConfig: CardHolderNameComponentConfig = {
  autoCapitalise: boolean,
  defaultValue: string,
  showHintIcon: boolean,
  showTooltip: boolean,
  hintIconSrc: string,
  dynamicCardImageComponent: DynamicCardImageComponent,
  inputAttributes: InputAttributes,
  required: boolean,
  placeholder: string,
  componentStyles: {
    base: CSSProperties,
    valid: CSSProperties,
    invalid: CSSProperties,
    input: CSSProperties
  },
  inputStyles: {
    base: CSSProperties,
    valid: CSSProperties,
    invalid: CSSProperties
  },
  label: string,
  labelStyles: {
    base: CSSProperties,
    valid: CSSProperties,
    invalid: CSSProperties
  },
  labelPosition: string,
  invalidTextStyles: CSSProperties,
  invalidTextPosition: string,
  guideText: string,
  validations: {},
  invalidIconSrc: string,
  validIconSrc: string,
  displayValidIcon: boolean,
  displayInvalidIcon: boolean,
  tooltipAriaLabel: string,
  ariaLabel: string,
  displayRequiredIcon: boolean,
  allowToCopyPaste: boolean,
  validationOnBlur: boolean,
  validationOnChange: boolean,
  tabIndex: number
};
PropertyDescription
autoCapitaliseWhether to convert the input to uppercase automatically.
defaultValueThe initial value for the name field.
showHintIconWhether to display a hint icon.
showTooltipWhether to display a tooltip on hint.
hintIconSrcThe URL to your custom hint icon.
dynamicCardImageComponentComponent to display dynamic card images. See Dynamic card image.
inputAttributesAdditional HTML input attributes.
requiredWhether the field is required for submission.
placeholderThe placeholder text to display when the field is empty.
componentStylesCustom styling for the component.
componentStyles.baseBase styling for the component.
componentStyles.validStyling for the component when it's valid.
componentStyles.invalidStyling for the component when it's not valid.
componentStyles.inputStyling for the input element.
inputStylesStyle for input field in various states.
labelThe input label's text.
labelStylesThe label styling, based on the state.

LabelPosition
The position of the label, relative to the input field.

Possible values:
  • above
  • below
  • left
  • right
invalidTextStylesStyle for validation message text.
invalidTextPositionThe position of the invalid text message, relative to the input field.

Possible values:
  • above
  • below
  • left
  • right
guideTextThe helper text to display below the input field.
validationsValidation rules to be applied to the input field.
invalidIconSrcThe URL for the icon shown on invalid input.
validIconSrcThe URL for the icon shown on valid input.
displayValidIconWhether to display a success icon. Defaults to true.
displayInvalidIconWhether to display an error icon. Defaults to true.
tooltipAriaLabelThe aria label for the tooltip.
ariaLabelThe aria label for the field component.
displayRequiredIconWhether to display a required icon. Defaults to true.
allowToCopyPasteWhether to allow copy/paste in the input fields.
validationOnBlurWhether to run validation when input loses focus.
validationOnChangeWhether to run validation as a value changes.
tabIndexThe tab index of the input element.

Callbacks

const cardCvcConfig: CardCvcComponentConfig = {
  onChange: (event: InputEvent) => void,
  onFocus: (event: FocusEvent) => void,
  onBlur: (event: FocusEvent) => void,
  onValidationPassed: (data: ValidationResult[]) => void,
  onValidationFailed: (data: ValidationResult[]) => void
};
CallbackDescription
onChange: (event: InputEvent) => voidEvent handler for when the input value changes.
onFocus: (event: FocusEvent) => voidEvent handler for when the input receives focus.
onBlur: (event: FocusEvent) => voidEvent handler for when the input loses focus.
onValidationPassed: (data: ValidationResult[]) => voidEvent handler for when all validations pass.
onValidationFailed: (data: ValidationResult[]) => voidEvent handler for when any validation fails.

For more information about callbacks, see Events.

Example

const cardHolderNameConfig: CardHolderNameComponentConfig = {
  label: "Cardholder name",
  placeholder: "John Smith",
  required: true,
  autoCapitalise: 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: 4,
  onChange: (event) => {
    console.log("Cardholder name changed:", event.target.value);
  },
  onFocus: (event) => {
    console.log("Cardholder name focused");
  },
  onBlur: (event) => {
    console.log("Cardholder name blurred");
  },
  onValidationPassed: (data) => {
    console.log("Cardholder name valid");
  },
  onValidationFailed: (data) => {
    console.log("Cardholder name validation failed:", data);
  }
};