Files
omni-tools/src/components/options/TextFieldWithDesc.tsx

37 lines
808 B
TypeScript
Raw Normal View History

2024-06-27 12:39:38 +01:00
import { Box, TextField, TextFieldProps } from '@mui/material';
2024-06-23 15:14:14 +01:00
import Typography from '@mui/material/Typography';
import React from 'react';
2024-06-27 12:39:38 +01:00
type OwnProps = {
2024-06-27 20:27:03 +01:00
description?: string;
2024-06-27 12:39:38 +01:00
value: string | number;
2024-06-27 21:25:11 +01:00
onOwnChange: (value: string) => void;
2024-06-27 12:39:38 +01:00
placeholder?: string;
};
2024-06-23 15:14:14 +01:00
const TextFieldWithDesc = ({
description,
value,
2024-06-27 21:25:11 +01:00
onOwnChange,
2024-06-27 12:39:38 +01:00
placeholder,
...props
}: TextFieldProps & OwnProps) => {
2024-06-23 15:14:14 +01:00
return (
<Box>
<TextField
placeholder={placeholder}
sx={{ backgroundColor: 'white' }}
value={value}
2024-06-27 21:25:11 +01:00
onChange={(event) => onOwnChange(event.target.value)}
2024-06-27 12:39:38 +01:00
{...props}
2024-06-23 15:14:14 +01:00
/>
2024-06-27 20:27:03 +01:00
{description && (
<Typography fontSize={12} mt={1}>
{description}
</Typography>
)}
2024-06-23 15:14:14 +01:00
</Box>
);
};
export default TextFieldWithDesc;