---
category: Utilities
---
# useToggle
A boolean switcher with utility functions.
## Usage
```ts
import { useToggle } from '@vueuse/core'
const [value, toggle] = useToggle()
```
When you pass a ref, `useToggle` will return a simple toggle function instead:
```ts
import { useDark, useToggle } from '@vueuse/core'
const isDark = useDark()
const toggleDark = useToggle(isDark)
```
Note: be aware that the toggle function accepts the first argument as the override value. You might want to avoid directly passing the function to events in the template, as the event object will pass in.
```html
```
## Type Declarations
```ts
export type ToggleFn = (value?: boolean) => void
export type UseToggleReturn = [ShallowRef, ToggleFn] | ToggleFn
export interface UseToggleOptions {
truthyValue?: MaybeRefOrGetter
falsyValue?: MaybeRefOrGetter
}
export declare function useToggle(
initialValue: Ref,
options?: UseToggleOptions,
): (value?: T) => T
export declare function useToggle<
Truthy = true,
Falsy = false,
T = Truthy | Falsy,
>(
initialValue?: T,
options?: UseToggleOptions,
): [ShallowRef, (value?: T) => T]
```