forked from sqlchat/sqlchat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextField.tsx
More file actions
41 lines (36 loc) · 879 Bytes
/
TextField.tsx
File metadata and controls
41 lines (36 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { HTMLInputTypeAttribute } from "react";
interface Props {
value: string;
onChange?: (value: string) => void;
type?: HTMLInputTypeAttribute;
className?: string;
disabled?: boolean;
placeholder?: string;
}
const getDefaultProps = () => ({
value: "",
onChange: () => {},
type: "text",
className: "",
disabled: false,
placeholder: "",
});
const TextField = (props: Props) => {
const { value, disabled, className, placeholder, type, onChange } = {
...getDefaultProps(),
...props,
};
return (
<input
className={`${
className || ""
} w-full border px-3 py-2 rounded-lg dark:border-zinc-700 dark:bg-zinc-800 focus:outline-2`}
type={type}
disabled={disabled}
placeholder={placeholder}
value={value}
onChange={(e) => onChange(e.target.value)}
/>
);
};
export default TextField;