Castle logo

CASTLE UI

search

Search

K
hexagon

useBoolean is a custom hook used to manage a boolean value with on, off and toggle functions.

Import

import { useBoolean } from '@passfort/castle'
content_copy

Copy

Return value

The useBoolean hook returns a stateful boolean value and an object with the following function to update it:

NameTypeDescription
on() => voidA function to set the boolean value to true.
off() => voidA function to set the boolean value to false.
toggle() => voidA function to negate the boolean state.

Usage

Usage of toggle method

content_copy

Copy

live example

Usage of on and off methods

content_copy

Copy

live example

Contents