On This Page
Toggling
Boolean Helpers
Signal helper for boolean values. Flips the stored value in place without a read-mutate-write round trip.
Toggling
toggle
signal.toggle();Sets the value to its boolean negation, notifying dependents when it changes. Equivalent to signal.mutate(value => !value).
Usage
import { signal } from '@semantic-ui/reactivity';
const isOpen = signal(false);isOpen.toggle(); // trueisOpen.toggle(); // falsetoggle() negates whatever is stored, so a truthy non-boolean becomes false and undefined becomes true. Start from a boolean to keep the value boolean.
toggle() negates whatever is stored, so a truthy non-boolean becomes false and undefined becomes true. Start from a boolean to keep the value boolean.