UNPKG

@loke/ui

Version:
61 lines (60 loc) 3.08 kB
import { Primitive } from "@loke/ui/primitive"; import { type ComponentPropsWithoutRef } from "react"; declare const createCollapsibleScope: import("@loke/ui/context").CreateScope; type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>; interface CollapsibleProps extends PrimitiveDivProps { /** Whether the collapsible is open by default. */ defaultOpen?: boolean; /** Whether the collapsible is disabled. */ disabled?: boolean; /** Callback when the open state changes. */ onOpenChange?(open: boolean): void; /** Whether the collapsible is open or closed. */ open?: boolean; } /** * Collapsible component for hiding and showing content * * The Collapsible component provides a way to toggle the visibility of content, allowing for a more compact UI that can expand to show additional information when needed. * * Key features: * - Controlled visibility of content * - Customizable trigger element * - Smooth transition effects * - Accessible keyboard navigation * * Usage considerations: * - Use for secondary or supplementary information that doesn't need to be always visible * - Ensure the trigger clearly indicates that there's hidden content * - Consider the impact on page layout when content expands * - Use in conjunction with icons or chevrons to indicate expandability */ declare const Collapsible: import("react").ForwardRefExoticComponent<CollapsibleProps & import("react").RefAttributes<HTMLDivElement>>; type PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>; type CollapsibleTriggerProps = PrimitiveButtonProps; /** * CollapsibleTrigger component for toggling the collapsible content * * This component renders a button that toggles the visibility of the associated CollapsibleContent. It automatically handles the open/close state and provides visual feedback. */ declare const CollapsibleTrigger: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & { asChild?: boolean; }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>; interface CollapsibleContentProps extends Omit<CollapsibleContentImplProps, "present"> { /** * Used to force mounting when more control is needed. Useful when * controlling animation with React animation libraries. */ forceMount?: true; } /** * CollapsibleContent component for the hideable content * * This component wraps the content that can be shown or hidden. It automatically handles the visibility based on the Collapsible's state and provides smooth transition effects. */ declare const CollapsibleContent: import("react").ForwardRefExoticComponent<CollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>>; interface CollapsibleContentImplProps extends PrimitiveDivProps { present: boolean; } export { createCollapsibleScope, Collapsible, CollapsibleTrigger, CollapsibleContent, }; export type { CollapsibleProps, CollapsibleTriggerProps, CollapsibleContentProps, };