# Cardholder name

Learn about customisation options for the cardholder name component.

## Styling


```typescript
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
};
```

| Property | Description |
|  --- | --- |
| `autoCapitalise` | Whether to convert the input to uppercase automatically. |
| `defaultValue` | The initial value for the name field. |
| `showHintIcon` | Whether to display a hint icon. |
| `showTooltip` | Whether to display a tooltip on hint. |
| `hintIconSrc` | The URL to your custom hint icon. |
| `dynamicCardImageComponent` | Component to display dynamic card images. See [Dynamic card image](/guides/checkout/components/web/card/dynamic-card-image). |
| `inputAttributes` | Additional HTML input attributes. |
| `required` | Whether the field is required for submission. |
| `placeholder` | The placeholder text to display when the field is empty. |
| `componentStyles` | Custom styling for the component. |
| `componentStyles.base` | Base styling for the component. |
| `componentStyles.valid` | Styling for the component when it's valid. |
| `componentStyles.invalid` | Styling for the component when it's not valid. |
| `componentStyles.input` | Styling for the input element. |
| `inputStyles` | Style for input field in various states. |
| `label` | The input label's text. |
| `labelStyles` | The label styling, based on the state. |
| LabelPosition | The position of the label, relative to the input field.Possible values:`above``below``left``right` |
| `invalidTextStyles` | Style for validation message text. |
| `invalidTextPosition` | The position of the invalid text message, relative to the input field.Possible values:`above``below``left``right` |
| `guideText` | The helper text to display below the input field. |
| `validations` | Validation rules to be applied to the input field. |
| `invalidIconSrc` | The URL for the icon shown on invalid input. |
| `validIconSrc` | The URL for the icon shown on valid input. |
| `displayValidIcon` | Whether to display a success icon. Defaults to `true`. |
| `displayInvalidIcon` | Whether to display an error icon. Defaults to `true`. |
| `tooltipAriaLabel` | The aria label for the tooltip. |
| `ariaLabel` | The aria label for the field component. |
| `displayRequiredIcon` | Whether to display a required icon. Defaults to `true`. |
| `allowToCopyPaste` | Whether to allow copy/paste in the input fields. |
| `validationOnBlur` | Whether to run validation when input loses focus. |
| `validationOnChange` | Whether to run validation as a value changes. |
| `tabIndex` | The tab index of the input element. |


## Callbacks


```typescript
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](/guides/checkout/components/web/card/events).

## Example


```typescript
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);
  }
};
```