CoastalCommitsPastes/client/app/components/input/index.tsx

39 lines
778 B
TypeScript
Raw Normal View History

2022-04-09 20:48:19 -04:00
import React from "react"
import styles from "./input.module.css"
type Props = React.HTMLProps<HTMLInputElement> & {
2022-04-09 20:48:19 -04:00
label?: string
2022-11-16 03:49:12 -05:00
width?: number | string
height?: number | string
}
// eslint-disable-next-line react/display-name
2022-04-09 20:48:19 -04:00
const Input = React.forwardRef<HTMLInputElement, Props>(
2022-11-16 03:49:12 -05:00
({ label, className, width, height, ...props }, ref) => {
const classes = [styles.input, styles.withLabel, className].join(" ")
2022-04-09 20:48:19 -04:00
return (
2022-11-16 03:49:12 -05:00
<div
className={styles.wrapper}
style={{
width,
height
}}
>
2022-04-09 20:48:19 -04:00
{label && <label className={styles.label}>{label}</label>}
<input
ref={ref}
2022-11-16 03:49:12 -05:00
className={classes}
2022-04-09 20:48:19 -04:00
{...props}
2022-11-16 03:49:12 -05:00
style={{
width,
height,
...(props.style || {})
}}
2022-04-09 20:48:19 -04:00
/>
</div>
)
}
)
export default Input