Back to Medusa

{metadata.title}

www/apps/ui/app/hooks/use-toggle-state/page.mdx

2.14.2882 B
Original Source

import { HookValues } from "@/components/HookValues" import { ComponentExample } from "@/components/ComponentExample"

export const metadata = { title: useToggleState, }

{metadata.title}

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.

<ComponentExample name="use-toggle-state-demo" hideFeedback />

Usage

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

API Reference

useToggleState Parameters

<HookValues hook="useToggleStateProps" />

useToggleState Return Value

<HookValues hook="useToggleStateReturn" hideFeedback />