Value: OFF

useToggle

A boolean switcher with utility functions.

Usage

import { useToggle } from '@vueuse/core'

const [value, toggle] = useToggle()

When you pass a ref, useTogglewill 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 https://vueuse.org/useToggle
 * @param [initialValue=false]
 */
export declare function useToggle(
  value: Ref<boolean>
): (value?: boolean) => boolean
export declare function useToggle(
  initialValue?: boolean
): [Ref<boolean>, (value?: boolean) => boolean]

Source

SourceDemoDocs