This repository has been archived on 2026-07-13. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
servicepoint-tanks/tank-frontend/src/components/TextInput.tsx
2024-05-07 13:21:10 +02:00

22 lines
623 B
TypeScript

import {ChangeEventHandler} from "react";
import './TextInput.css';
export default function TextInput( {onChange, className, value, placeholder, onEnter }: {
onChange?: ChangeEventHandler<HTMLInputElement> | undefined;
className?: string;
value: string;
placeholder: string;
onEnter?: () => void;
}) {
return <input
type="text"
className={'TextInput ' + (className?? '')}
value={value}
placeholder={placeholder}
onChange={onChange}
onKeyUp={event => {
if (onEnter && event.key === 'Enter')
onEnter();
}}
/>;
}