diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-16 13:40:12 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-16 13:40:12 +0100 |
| commit | eb459cc248a5940a14193b20d263ffee3d345026 (patch) | |
| tree | 92ea7b91d4481b4b61f86bef5299227e0bca1c3d /src/components/Form/TextArea | |
| parent | 94f1c1fbea903e677476a167e51b549bb0c53330 (diff) | |
chore: create contact page
Diffstat (limited to 'src/components/Form/TextArea')
| -rw-r--r-- | src/components/Form/TextArea/TextArea.tsx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/components/Form/TextArea/TextArea.tsx b/src/components/Form/TextArea/TextArea.tsx new file mode 100644 index 0000000..729ef6d --- /dev/null +++ b/src/components/Form/TextArea/TextArea.tsx @@ -0,0 +1,42 @@ +import { ChangeEvent, SetStateAction } from 'react'; +import styles from '../Form.module.scss'; + +const TextArea = ({ + id, + name, + value, + setValue, + required = false, + label, +}: { + id: string; + name: string; + value: string; + setValue: (value: SetStateAction<string>) => void; + required?: boolean; + label?: string; +}) => { + const updateValue = (e: ChangeEvent<HTMLTextAreaElement>) => { + setValue(e.target.value); + }; + + return ( + <> + {label && ( + <label htmlFor={id} className={styles.label}> + {label} + {required && <span> *</span>} + </label> + )} + <textarea + id={id} + name={name} + value={value} + onChange={updateValue} + className={`${styles.field} ${styles.textarea}`} + /> + </> + ); +}; + +export default TextArea; |
