Value: OFF
useToggle
A boolean switcher with utility functions.
Usage
import { useToggle } from '@vueuse/core'
const [value, toggle] = useToggle()
When you pass a ref, useToggle
will return a simple toggle function instead:
import { useDark, useToggle } from '@vueuse/core'
const isDark = useDark()
const toggleDark = useToggle(isDark)
Type Declarations
/**
* A boolean ref with a toggler
*
* @see /useToggle
* @param [initialValue=false]
*/
export declare function useToggle(value: Ref<boolean>): () => boolean
export declare function useToggle(
initialValue?: boolean
): [Ref<boolean>, () => boolean]