Website/components/textbox.js

14 lines
623 B
JavaScript

import styles from '../styles/Textbox.module.css'
export default function Textbox(props) {
return (
<input className={styles.Textbox} type={props.type ?? 'text'} style={{width: props.width ?? '200px', ...props.style}} placeholder={props.placeholder ?? 'Type anything here!'} defaultValue={props.value ?? ""} onKeyDown={() => {
if (props.submitOnEnter && event.key === 'Enter' && props.submit) {
props.submit(event.target.value);
// props.value = ""; // this is not how you do it
event.target.value = "";
}
}}></input>
)
}