useToggleState

This hook tracks a boolean value and toggles between its two states.

This guide explains how to use the useToggleState hook.

For example, you can use this hook to display a checkbox or a Switch that toggles a Focus Modal.

Entity NameActions
foo
bar
baz

Usage#

Code
import { useToggleState } from "@medusajs/ui"
Code
const [state, open, close, toggle] = useToggleState()

API Reference#

useToggleState Parameters#

NameTypeDefault
initial
booleanfalse
Was this guide helpful?

useToggleState Return Value#

NameTypeDescription
state
StateData
-
Was this guide helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break