diff --git a/docs/admin/hooks.mdx b/docs/admin/hooks.mdx index 3094b90902..4da4bd7e0d 100644 --- a/docs/admin/hooks.mdx +++ b/docs/admin/hooks.mdx @@ -635,6 +635,37 @@ export const CustomArrayManager = () => { ]} /> +### useCollapsible + +The `useCollapsible` hook allows you to control parent collapsibles: + +| Property | Description | +|---------------------------|--------------------------------------------------------------------------------------------------------------------| +| **`collapsed`** | State of the collapsible. `true` if open, `false` if collapsed | +| **`isVisible`** | If nested, determine if the nearest collapsible is visible. `true` if no parent is closed, `false` otherwise | +| **`toggle`** | Toggles the state of the nearest collapsible | +| **`withinCollapsible`** | Determine when you are within another collaspible | | + +**Example:** + +```tsx +import React from 'react' + +import { useCollapsible } from 'payload/components/utilities' + +const CustomComponent: React.FC = () => { + const { collapsed, toggle } = useCollapsible() + return ( +
+

I am {collapsed ? 'closed' : 'open'}

+ +
+ ) +} +``` + ### useDocumentInfo The `useDocumentInfo` hook provides lots of information about the document currently being edited, including the following: @@ -774,8 +805,8 @@ const MyComponent: React.FC = () => { return ( <> The current theme is {theme} and autoMode is {autoMode} -