Skip to content

Commit a9e40cb

Browse files
chore: update demo classes
1 parent 0aa6f0b commit a9e40cb

2 files changed

Lines changed: 13 additions & 70 deletions

File tree

apps/showcase/demo/inputotp/custom-demo.tsx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@ import { InputOtp } from 'primereact/inputotp';
44
export default function CustomDemo() {
55
return (
66
<div className="card flex justify-center">
7-
<style scoped>
8-
{`
9-
.custom-otp-input {
10-
width: 40px;
11-
font-size: 36px;
12-
border: 0 none;
13-
appearance: none;
14-
text-align: center;
15-
transition: all 0.2s;
16-
background: transparent;
17-
border-bottom: 2px solid var(--p-inputtext-border-color);
18-
}
19-
20-
.custom-otp-input:focus {
21-
outline: 0 none;
22-
border-bottom-color: var(--p-primary-color);
23-
}
24-
`}
25-
</style>
267
<InputOtp defaultValue={''}>
278
{(instance: InputOtpInstance) => {
289
const { onInput, onClick, onKeyDown, onPaste, state, registerText } = instance;
@@ -38,7 +19,7 @@ export default function CustomDemo() {
3819
key={index}
3920
type="text"
4021
inputMode="text"
41-
className="custom-otp-input"
22+
className="w-10 text-4xl border-0 appearance-none text-center transition-all duration-200 bg-transparent border-b-2 border-b-[var(--p-inputtext-border-color)] focus:outline-none focus:border-b-[var(--p-primary-color)]"
4223
maxLength={1}
4324
onInput={(e) => onInput(e, index)}
4425
onClick={onClick}

apps/showcase/demo/inputotp/sample-demo.tsx

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,6 @@ import * as React from 'react';
77
export 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

Comments
 (0)