ldc-bien-etre-animal/resources/ts/front/Components/Form/FormSelect.tsx
2026-09-08 13:17:18 +02:00

54 lines
1.4 KiB
TypeScript

import { ChevronDown } from "lucide-react";
import { type SelectHTMLAttributes } from "react";
interface Option {
label: string;
value: string;
}
type FormSelectProps = SelectHTMLAttributes<HTMLSelectElement> & {
label: string;
options: Option[];
required?: boolean;
error?: string;
};
export default function FormSelect({
label,
options,
required,
error,
className = "",
...props
}: Readonly<FormSelectProps>) {
return (
<div className="relative w-full">
<select
defaultValue={props.value === undefined ? "" : undefined}
{...props}
required={required}
className={`w-full cursor-pointer uppercase appearance-none rounded-full border-4 bg-white bg-none px-6 py-4 font-poppins-bold text-body text-bleu outline-none [&::-ms-expand]:hidden
${className}
${error ? "border-rouge" : "border-bleu"}
`}
style={{ WebkitAppearance: "none", MozAppearance: "none" }}
>
<option value="" disabled>
{label}
{required ? "*" : ""}
</option>
{options.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
<ChevronDown
size={28}
strokeWidth={3}
className="pointer-events-none absolute right-6 top-1/2 -translate-y-1/2 text-bleu"
/>
</div>
);
}