use-toggle
Switch between two states
Import
Source
Docs
Package
Usage
Hook implements common state pattern – it switches state between two given values:
API
Hook accepts two arguments:
initialValue
– initial stateoptions
– an array with 2 elements, must include initial value
Hook returns an array with state value and toggle function:
use-boolean-toggle
use-boolean-toggle is a wrapper around use-toggle that works with boolean values:
TypeScript
Set type
By default TypeScript will guess your type, but in most cases it's better to set type manually:
Definition
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback