sendou.ink/components/common/ChakraSelect.tsx
2020-12-17 15:00:31 +02:00

31 lines
564 B
TypeScript

import { Select } from "@chakra-ui/react";
interface Props {
value: string;
setValue: (value?: string) => void;
placeholder?: string;
name?: string;
children: React.ReactNode;
}
const ChakraSelect: React.FC<Props> = ({
value,
setValue,
placeholder,
children,
name,
}) => (
<Select
value={value ?? ""}
onChange={(e) =>
setValue(e.target.value === "" ? undefined : e.target.value)
}
name={name}
>
{placeholder && <option value="">{placeholder}</option>}
{children}
</Select>
);
export default ChakraSelect;