File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,13 @@ const handlePaste: React.ClipboardEventHandler<HTMLDivElement> = (event) => {
145
145
<td>false</td>
146
146
<td>Auto focuses input on initial page load.</td>
147
147
</tr >
148
+ <tr >
149
+ <td>skipDefaultStyles</td>
150
+ <td>boolean</td>
151
+ <td>false</td>
152
+ <td>false</td>
153
+ <td>The component comes with default styles for legacy reasons. Pass <code>true</code> to skip those styles. This prop will be removed in the next major release.</td>
154
+ </tr >
148
155
</table >
149
156
150
157
### ⚠️ Warning
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-otp-input" ,
3
- "version" : " 3.0.4 " ,
3
+ "version" : " 3.1.0 " ,
4
4
"description" : " A fully customizable, one-time password input component for the web built with React" ,
5
5
"main" : " lib/index.js" ,
6
6
"module" : " lib/index.esm.js" ,
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ interface OTPInputProps {
48
48
inputStyle ?: React . CSSProperties | string ;
49
49
/** The type that will be passed to the input being rendered */
50
50
inputType ?: AllowedInputTypes ;
51
+ /** Do not apply the default styles to the inputs, will be removed in future versions */
52
+ skipDefaultStyles ?: boolean ; // TODO: Remove in next major release
51
53
}
52
54
53
55
const isStyleObject = ( obj : unknown ) => typeof obj === 'object' && obj !== null ;
@@ -64,6 +66,7 @@ const OTPInput = ({
64
66
placeholder,
65
67
containerStyle,
66
68
inputStyle,
69
+ skipDefaultStyles = false ,
67
70
} : OTPInputProps ) => {
68
71
const [ activeInput , setActiveInput ] = React . useState ( 0 ) ;
69
72
const inputRefs = React . useRef < Array < HTMLInputElement | null > > ( [ ] ) ;
@@ -238,8 +241,8 @@ const OTPInput = ({
238
241
maxLength : 1 ,
239
242
'aria-label' : `Please enter OTP character ${ index + 1 } ` ,
240
243
style : Object . assign (
241
- { width : '1em' , textAlign : 'center' } as const ,
242
- isStyleObject ( inputStyle ) && inputStyle
244
+ ! skipDefaultStyles ? ( { width : '1em' , textAlign : 'center' } as const ) : { } ,
245
+ isStyleObject ( inputStyle ) ? inputStyle : { }
243
246
) ,
244
247
className : typeof inputStyle === 'string' ? inputStyle : undefined ,
245
248
type : inputType ,
You can’t perform that action at this time.
0 commit comments