CheckboxWithLabel is a React component that allows users to toggle between two labels on a checkbox. It uses the useState hook from React to keep track of the checkbox's state.
CheckboxWithLabel takes two props - labelOn and labelOff - to set the labels for when the checkbox is checked and unchecked respectively.
<CheckboxWithLabel
labelOn="On"
labelOff="Off"
/>
Below is an example of how to use the CheckboxWithLabel component.
import React from 'react';
import CheckboxWithLabel from './CheckboxWithLabel';
function App() {
return (
<div>
<CheckboxWithLabel
labelOn="On"
labelOff="Off"
/>
</div>
);
}
export default App;
This renders a checkbox with the label "Off" and when clicked, it will toggle to "On".