@payfit/unity-components
Version:
57 lines (56 loc) • 2.83 kB
TypeScript
import { ReactNode } from 'react';
import { DisclosureProps } from 'react-aria-components/Disclosure';
import { collapsible } from './Collapsible.variants.js';
import { VariantProps } from 'tailwind-variants';
export interface CollapsibleProps extends VariantProps<typeof collapsible>, Omit<DisclosureProps, 'className'> {
/**
* The content of the collapsible component.
* Typically includes a CollapsibleTitle and CollapsibleContent.
*/
children: ReactNode;
/**
* Controls whether the collapsible is expanded.
* Use this prop with `onExpandedChange` when another component owns the expanded state.
* @default false
*/
isExpanded?: boolean;
}
/**
* Hides and reveals a section of content behind an accessible disclosure trigger.
* Use `Collapsible` to keep optional or secondary information available without keeping every detail visible at once.
* Compose it with `CollapsibleTitle` for the trigger and `CollapsibleContent` for the revealed panel.
* @param {CollapsibleProps} props - React Aria disclosure props, Unity visual variant props, and composed title/content children.
* @example
* ```tsx
* import {
* Collapsible,
* CollapsibleContent,
* CollapsibleTitle,
* } from '@payfit/unity-components'
*
* function Example() {
* return (
* <Collapsible>
* <CollapsibleTitle>Section Title</CollapsibleTitle>
* <CollapsibleContent>
* Content that can be shown or hidden
* </CollapsibleContent>
* </Collapsible>
* )
* }
* ```
* @remarks
* - Set `defaultExpanded` to make an uncontrolled collapsible open on first render.
* - Set `isExpanded` with `onExpandedChange` when the expanded state is controlled elsewhere.
* - Set `variant` to `outlined` or `filled` when the section needs stronger visual separation.
* - Wrap several related collapsibles in `CollapsibleGroup` when the expanded state must be coordinated across sections.
* @see {@link CollapsibleProps} for all available props.
* @see {@link CollapsibleTitle} for the clickable title component.
* @see {@link CollapsibleContent} for the revealed content panel.
* @see Source code in {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/components/collapsible GitHub}
* @see Design specs {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=7034-34016 Figma}
* @see Design docs in {@link https://www.payfit.design/24f360409/p/816353-collapsible PayFit.design}
* @see Developer docs in {@link https://unity-components.payfit.io/?path=/docs/component-reference-collapsible--docs unity-components.payfit.io}
*/
declare const Collapsible: import('react').ForwardRefExoticComponent<CollapsibleProps & import('react').RefAttributes<HTMLDivElement>>;
export { Collapsible };