Switch
A control that allows the user to toggle between checked and not checked.
# Demo
# Attributes
Name | Type | Default | Details |
---|---|---|---|
className | string | ' ' | You can customise by passing tailwind classes. |
labelClassName | string | ' ' | You can customise by passing tailwind classes. |
switchClassName | string | ' ' | You can customise by passing tailwind classes. |
label | string | ' ' | You can pass label to switch. |
enabled | boolean | false | You can pass enabled to switch. |
disabled | boolean | false | You can pass disabled to switch. |
onChange | (enabled: boolean) => void | Required | You 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;