The TextFieldsProps prop allows you to customize the individual input fields (rendered via TextFieldBox). It can be provided in two ways:
- As an object: The same props will be applied to every input field.
- As a function: Receives the current
index as an argument, allowing you to apply different props to specific fields (e.g., different styling for the last field).
Note that MuiOtpInput internally handles onPaste, onFocus, onKeyDown, onBlur, onChange, and inputRef, so you should be careful when overriding these if you want to maintain the component's core functionality.
// Using a function to customize fields based on index
<MuiOtpInput
value={otp}
length={4}
onChange={setOtp}
TextFieldsProps={(index) => ({
variant: 'outlined',
sx: { borderRadius: index === 3 ? '50%' : '4px' }
})}
/>