1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import React from 'react';
- interface FormSelectProps {
- id: string;
- label: string;
- value: string;
- onChange: (value: string) => void;
- options: { value: string; label: string }[];
- disabled?: boolean;
- placeholder?: string;
- }
- export default function FormSelect({
- id,
- label,
- value,
- onChange,
- options,
- disabled = false,
- placeholder
- }: FormSelectProps) {
- return (
- <div>
- <label htmlFor={id} className="block text-sm font-medium text-gray-700 mb-1">
- {label}
- </label>
- <select
- id={id}
- value={value}
- onChange={(e) => onChange(e.target.value)}
- disabled={disabled}
- className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 disabled:bg-gray-100 disabled:cursor-not-allowed"
- >
- {placeholder && (
- <option value="" disabled>
- {placeholder}
- </option>
- )}
- {options.map((option) => (
- <option key={option.value} value={option.value}>
- {option.label}
- </option>
- ))}
- </select>
- </div>
- );
- }
|