File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 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) => {
145145 <td>false</td>
146146 <td>Auto focuses input on initial page load.</td>
147147 </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 >
148155</table >
149156
150157### ⚠️ Warning
Original file line number Diff line number Diff line change 11{
22 "name" : " react-otp-input" ,
3- "version" : " 3.0.4 " ,
3+ "version" : " 3.1.0 " ,
44 "description" : " A fully customizable, one-time password input component for the web built with React" ,
55 "main" : " lib/index.js" ,
66 "module" : " lib/index.esm.js" ,
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ interface OTPInputProps {
4848 inputStyle ?: React . CSSProperties | string ;
4949 /** The type that will be passed to the input being rendered */
5050 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
5153}
5254
5355const isStyleObject = ( obj : unknown ) => typeof obj === 'object' && obj !== null ;
@@ -64,6 +66,7 @@ const OTPInput = ({
6466 placeholder,
6567 containerStyle,
6668 inputStyle,
69+ skipDefaultStyles = false ,
6770} : OTPInputProps ) => {
6871 const [ activeInput , setActiveInput ] = React . useState ( 0 ) ;
6972 const inputRefs = React . useRef < Array < HTMLInputElement | null > > ( [ ] ) ;
@@ -238,8 +241,8 @@ const OTPInput = ({
238241 maxLength : 1 ,
239242 'aria-label' : `Please enter OTP character ${ index + 1 } ` ,
240243 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 : { }
243246 ) ,
244247 className : typeof inputStyle === 'string' ? inputStyle : undefined ,
245248 type : inputType ,
You can’t perform that action at this time.
0 commit comments