@@ -7,45 +7,6 @@ import * as React from 'react';
77export default function SampleDemo ( ) {
88 return (
99 < div className = "card flex justify-center" >
10- < style scoped >
11- { `
12- .custom-otp-input-sample {
13- width: 48px;
14- height: 48px;
15- font-size: 24px;
16- appearance: none;
17- text-align: center;
18- transition: all 0.2s;
19- border-radius: 0;
20- border: 1px solid var(--p-inputtext-border-color);
21- background: transparent;
22- outline-offset: -2px;
23- outline-color: transparent;
24- border-right: 0 none;
25- transition: outline-color 0.3s;
26- color: var(--p-inputtext-color);
27- }
28-
29- .custom-otp-input-sample:focus {
30- outline: 2px solid var(--p-focus-ring-color);
31- }
32-
33- .custom-otp-input-sample:first-child,
34- .custom-otp-input-sample:nth-child(5) {
35- border-top-left-radius: 12px;
36- border-bottom-left-radius: 12px;
37- }
38-
39- .custom-otp-input-sample:nth-child(3),
40- .custom-otp-input-sample:last-child {
41- border-top-right-radius: 12px;
42- border-bottom-right-radius: 12px;
43- border-right-width: 1px;
44- border-right-style: solid;
45- border-color: var(--p-inputtext-border-color);
46- }
47- ` }
48- </ style >
4910 < div className = "flex flex-col items-center" >
5011 < div className = "font-bold text-xl mb-2" > Authenticate Your Account</ div >
5112 < p className = "text-surface-500 dark:text-surface-400 block mb-8" > Please enter the code sent to your phone.</ p >
@@ -58,19 +19,20 @@ export default function SampleDemo() {
5819 { Array . from ( { length : 6 } , ( _ , index ) => {
5920 registerText ( ) ;
6021
22+ const inputClasses = [
23+ 'w-12 h-12 text-2xl appearance-none text-center transition-all duration-200' ,
24+ 'border border-[var(--p-inputtext-border-color)] bg-transparent' ,
25+ 'outline-offset-[-2px] outline-transparent transition-[outline-color] duration-300' ,
26+ 'text-[var(--p-inputtext-color)]' ,
27+ index === 0 || index === 3 ? 'rounded-l-xl' : 'rounded-none' ,
28+ index === 2 || index === 5 ? 'rounded-r-xl' : '' ,
29+ ! ( index === 2 || index === 5 ) ? 'border-r-0' : '' ,
30+ 'focus:outline-2 focus:outline-[var(--p-focus-ring-color)]'
31+ ] . join ( ' ' ) ;
32+
6133 return (
6234 < React . Fragment key = { index } >
63- < input
64- value = { state . tokens [ index ] ?? '' }
65- type = "text"
66- inputMode = "text"
67- className = "custom-otp-input-sample"
68- maxLength = { 1 }
69- onInput = { ( e ) => onInput ( e , index ) }
70- onClick = { onClick }
71- onKeyDown = { onKeyDown }
72- onPaste = { onPaste }
73- />
35+ < input value = { state . tokens [ index ] ?? '' } type = "text" inputMode = "text" className = { inputClasses } maxLength = { 1 } onInput = { ( e ) => onInput ( e , index ) } onClick = { onClick } onKeyDown = { onKeyDown } onPaste = { onPaste } />
7436 { index === 2 && (
7537 < div className = "px-4" >
7638 < MinusIcon />
0 commit comments