form-checkbox.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react';
  2. interface FormCheckboxProps {
  3. id: string;
  4. label: string;
  5. checked: boolean;
  6. onChange: (checked: boolean) => void;
  7. disabled?: boolean;
  8. description?: string;
  9. }
  10. export default function FormCheckbox({
  11. id,
  12. label,
  13. checked,
  14. onChange,
  15. disabled = false,
  16. description
  17. }: FormCheckboxProps) {
  18. return (
  19. <div className="flex items-start">
  20. <div className="flex items-center h-5">
  21. <input
  22. id={id}
  23. type="checkbox"
  24. checked={checked}
  25. onChange={(e) => onChange(e.target.checked)}
  26. disabled={disabled}
  27. className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2"
  28. />
  29. </div>
  30. <div className="ml-3 text-sm">
  31. <label
  32. htmlFor={id}
  33. className={`font-medium ${disabled ? 'text-gray-400' : 'text-gray-700'}`}
  34. >
  35. {label}
  36. </label>
  37. {description && (
  38. <p className="text-gray-500 mt-1">{description}</p>
  39. )}
  40. </div>
  41. </div>
  42. );
  43. }