-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
52 lines (49 loc) · 1.46 KB
/
index.tsx
File metadata and controls
52 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {HTMLInputTypeAttribute} from 'react'
import {cn} from '@/utils/toolbox'
import React, {forwardRef} from 'react'
export type InputProps = {
id: string
label: string
labelSrOnly?: boolean
className?: string
type?: HTMLInputTypeAttribute
error?: string
placeholder?: string
}
const Input = forwardRef<HTMLInputElement, InputProps & Omit<JSX.IntrinsicElements['input'], 'type'>>(
({id, label, className, type = 'text', error, labelSrOnly, ...other}, ref) => {
return (
<div className={className}>
<label
htmlFor={id}
className={cn('block text-base font-normal leading-6 text-white', labelSrOnly ? 'sr-only' : 'mb-2.5')}
>
{label}
</label>
<div>
<input
type={type}
id={id}
ref={ref}
{...other}
className={cn(
'block w-full rounded-full border-0 bg-slate-900 px-3.5 py-2 text-slate-400 font-light shadow-sm ring-1 \
ring-inset ring-slate-700/60 focus:ring-2 focus:ring-inset focus:ring-primary-500 sm:text-sm sm:leading-6',
error && 'text-red-900 ring-red-500 focus:ring-red-500'
)}
/>
{error ? (
<p
className='mt-2 text-sm text-red-600'
id={`${id}-error`}
>
{error}
</p>
) : null}
</div>
</div>
)
}
)
Input.displayName = 'Input'
export default Input