Switch

A control that allows the user to toggle between checked and not checked.
# Demo
# Attributes
NameTypeDefaultDetails
classNamestring' 'You can customise by passing tailwind classes.
labelClassNamestring' 'You can customise by passing tailwind classes.
switchClassNamestring' 'You can customise by passing tailwind classes.
labelstring' 'You can pass label to switch.
enabledbooleanfalseYou can pass enabled to switch.
disabledbooleanfalseYou can pass disabled to switch.
onChange(enabled: boolean) => voidRequiredYou can get callback when switch changed.
# Usage
import { useState } from 'react'; import { NSwitch } from 'nayan'; const Switch = () => { const [enabled, setEnabled] = useState(false); return <NSwitch label="Is Dark Mode" enabled={enabled} onChange={setEnabled} />; }; export default Switch;