Class: Toggle
Description:
The Toggle
component is a reusable UI element that provides a visually appealing and interactive way to toggle a boolean state. It utilizes the InputSwitch
component from primereact
library for the underlying switch functionality.
Parameters:
state
(boolean
): The current state of the toggle.onChange
(Function
): A callback function that is triggered when the toggle state changes. It receives the new state as an argument.className
(string
): An optional CSS class name to apply to the toggle container....props
: Any additional props that will be passed down to theInputSwitch
component.
Returns:
- JSX element: A
div
element containing theInputSwitch
component styled to represent a toggle.
Example:
<Toggle
state={false}
onChange={(newState) => {
console.log(`Toggle state changed to ${newState}`);
}}
className="my-custom-toggle"
/>