import { SelectHTMLAttributes, forwardRef, ReactNode } from 'react';
interface SelectProps extends SelectHTMLAttributes {
label?: ReactNode;
error?: string;
options: { value: string | number; label: string }[];
placeholder?: string;
}
const Select = forwardRef(
({ className = '', label, error, options, id, placeholder = 'Bitte wählen...', ...props }, ref) => {
const selectId = id || props.name;
// Wenn keine Breitenklasse in className, dann w-full als Standard
const hasWidthClass = /\bw-\d+\b|\bw-\[|\bflex-/.test(className);
return (
{label && (
)}
{error &&
{error}
}
);
}
);
Select.displayName = 'Select';
export default Select;