![Logo](/_astro/logo.DNC1PCTe_Z1abT04.webp)
ctrl+k
Enter a search term above to see results...
Enter a search term above to see results...
Boolean Helpers are methods available on Signal instances that contain boolean values. These helpers provide a convenient way to toggle the state of a boolean reactive variable.
Switches the boolean value of the Signal to its opposite state.
signal.toggle()
boolean - The new value after toggling.
import { Signal } from '@semantic-ui/reactivity';
const isActive = new Signal(false);
console.log(isActive.get()); // Output: false
isActive.toggle();console.log(isActive.get()); // Output: true
isActive.toggle();console.log(isActive.get()); // Output: false
toggle()
method is particularly useful for managing binary states in your application, such as showing/hiding elements, enabling/disabling features, or switching between two modes.toggle()
will trigger any reactive computations that depend on this variable.