UNPKG

@base-ui/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

51 lines 1.79 kB
import * as React from 'react'; import { TransitionStatus } from "../../internals/useTransitionStatus.js"; import type { CollapsibleRoot } from "./CollapsibleRoot.js"; export declare function useCollapsibleRoot(parameters: UseCollapsibleRootParameters): UseCollapsibleRootReturnValue; export interface UseCollapsibleRootParameters { /** * Whether the collapsible panel is currently open. * * To render an uncontrolled collapsible, use the `defaultOpen` prop instead. */ open?: boolean | undefined; /** * Whether the collapsible panel is initially open. * * To render a controlled collapsible, use the `open` prop instead. * @default false */ defaultOpen?: boolean | undefined; /** * Event handler called when the panel is opened or closed. */ onOpenChange: (open: boolean, eventDetails: CollapsibleRoot.ChangeEventDetails) => void; /** * Whether the component should ignore user interaction. * @default false */ disabled: boolean; } export interface UseCollapsibleRootReturnValue { /** * Whether the component should ignore user interaction. */ disabled: boolean; handleTrigger: (event: React.MouseEvent | React.KeyboardEvent) => void; /** * Whether the collapsible panel is mounted for transition and hidden-state * purposes. This can be `false` while the element remains in the DOM when * `keepMounted` or `hiddenUntilFound` is enabled. */ mounted: boolean; /** * Whether the collapsible panel is currently open. */ open: boolean; panelId: React.HTMLAttributes<Element>['id']; setMounted: (nextMounted: boolean) => void; setOpen: (open: boolean) => void; setPanelIdState: (id: string | undefined) => void; transitionStatus: TransitionStatus; } export interface UseCollapsibleRootState {}