TextInput.tsx 492 B

1234567891011121314151617
  1. import { FunctionComponent, InputHTMLAttributes } from "react"
  2. import styles from './forms.module.css';
  3. interface TextInputProps extends InputHTMLAttributes<HTMLInputElement> {
  4. label?: string
  5. }
  6. export const TextInput: FunctionComponent<TextInputProps> = ({ label, id, ...props }) => (
  7. <div className={styles.input}>
  8. {label && <label htmlFor={id}>{label}</label>}
  9. <input className={styles.textInput} id={id} {...props} />
  10. </div>
  11. );
  12. TextInput.defaultProps = {
  13. type: 'text',
  14. }