interstellar_ai/app/components/settings/CheckBox.tsx

32 lines
1,010 B
TypeScript
Raw Permalink Normal View History

2024-10-01 12:45:21 +02:00
import React from 'react';
// Define the props for the CheckboxSetting component
2024-10-01 12:45:21 +02:00
interface CheckboxSettingProps {
label: string; // The label to display
checked: boolean; // The checked state of the checkbox
setChecked: (value: boolean) => void; // Method to update the state
}
// Functional component definition
2024-10-01 12:45:21 +02:00
const CheckboxSetting: React.FC<CheckboxSettingProps> = ({ label, checked, setChecked }) => {
// Handler to toggle the checkbox state
2024-10-01 12:45:21 +02:00
const handleCheckboxChange = () => {
setChecked(!checked); // Toggle the checked state
2024-10-01 12:45:21 +02:00
};
return (
<div className="settings-option"> {/* Container for the checkbox setting */}
2024-10-01 12:45:21 +02:00
<label>
<input
type="checkbox" // Checkbox input type
checked={checked} // Set the checked state based on the prop
onChange={handleCheckboxChange} // Call the handler on change
2024-10-01 12:45:21 +02:00
/>
{label} {/* Display the label next to the checkbox */}
2024-10-01 12:45:21 +02:00
</label>
</div>
);
};
export default CheckboxSetting;