Skip to content

Instantly share code, notes, and snippets.

@Shivam38391
Created March 20, 2024 04:40
Show Gist options
  • Save Shivam38391/d666b56c881d2babc859b5bb39cca041 to your computer and use it in GitHub Desktop.
Save Shivam38391/d666b56c881d2babc859b5bb39cca041 to your computer and use it in GitHub Desktop.
production level react component input.jsx
import React, { useId, ref } from 'react'
const Input = React.forwardRef(function Input({
label,
type = 'text',
className = "",
...props
}, ref) {
const id = useId();
return (
<div className='w-full' >
{label && <label className='inline-block mb-1 text-[14px] font-medium text-neutral500' htmlFor={id}>{label}</label>}
<input
id={id} type={type}
className={` bg-white text-neutral500 p-2 rounded-lg border border-neutral100 w-full focus:border-[#000000] ${className}`}
ref={ref} {...props} />
</div>
)
})
export default Input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment