Toggle Components
Examples
<script>
import { Toggle } from 'flowbite-svelte'
let props = {
name: 'toggle-example',
id: 'toggle-example',
label: 'Toggle me',
labelClass: 'flex relative items-center mb-4 cursor-pointer',
divClass:
'w-11 h-6 bg-gray-200 rounded-full border border-gray-200 toggle-bg dark:bg-gray-700 dark:border-gray-600',
spanClass: 'ml-3 text-sm font-medium text-gray-900 dark:text-gray-300',
checked: false,
disabled: false
};
let props2 = {
name: 'toggle-example-checked',
id: 'toggle-example-checked',
label: 'Toggle me (checked)',
checked: true,
disabled: false
};
let props3 = {
name: 'toggle-example-disabled',
id: 'toggle-example-disabled',
label: 'Toggle me (disabled)',
checked: false,
disabled: true
};
let textareaprops = {
id: 'message',
name: 'message',
label: 'Your message',
rows: 4,
placeholder: 'Leave a comment...',
};
</script>
<Toggle {...props}/>
<Toggle {...props2}/>
<Toggle {...props3}/>
Props
The component has the following props, type, and default values. See type-list page for type information.
Name | Type | Default |
---|---|---|
name | string | 'toggle-example' |
id | string | generateId() |
label | string | 'Toggle me' |
checked | boolean | false |
disabled | boolean | false |
labelClass | string | 'flex relative items-center mb-4 cursor-pointer' |
divClass | string | 'w-11 h-6 bg-gray-200 rounded-full border border-gray-200 toggle-bg dark:bg-gray-700 dark:border-gray-600' |
spanClass | string | 'ml-3 text-sm font-medium text-gray-900 dark:text-gray-300' |