Skip to content

useCollapsible

@astryxdesign/core v0.7.1 · useCollapsible

Parameters ​

NameTypeDefaultDescription
isCollapsibleboolean | CollapsibleConfig | MaybeRefOrGettertrueWhether collapsible behavior is active. true manages its own state and starts open. false disables folding. Pass a config object for controlled mode or a custom default.
valuestring | undefined | MaybeRefOrGetter—Unique identifier within a CollapsibleGroup. When present and inside a group, the group owns the state.
groupCollapsibleGroupContextValue | nullinjectedGroup context. Read from the nearest CollapsibleGroup when omitted; pass it explicitly only when you are outside that tree.

CollapsibleConfig ​

FieldTypeDefaultDescription
isOpenRef<boolean | undefined>—Controlled open state, usually the v-model:isOpen model ref. Leave it out for uncontrolled state.
defaultIsOpenboolean | MaybeRefOrGettertrueOpen state while isOpen stays unbound.
onOpenChange(isOpen: boolean) => void—Called with the requested state. In controlled usage it is the request; in uncontrolled usage it is the report.

Returns ​

FieldTypeDescription
isEnabledComputedRef<boolean>Whether collapsible behavior is active. False when isCollapsible is false.
isOpenComputedRef<boolean>Whether the content is currently expanded.
toggle() => voidToggle open/closed state. Dispatches to the group, the controlled ref, or internal state.