@coniungo/ui
Version:
A customizable, accessible, and developer-friendly React UI component library powered by Tailwind CSS, TypeScript, and Vite
14 lines (13 loc) • 545 B
TypeScript
import { KeyboardEvent, RefCallback } from 'react';
type UseAccordionParams<T, K extends keyof T = keyof T> = {
items: T[];
idKey?: K;
};
export declare function useAccordion<T, K extends keyof T = keyof T>({ items, idKey, }: UseAccordionParams<T, K>): {
openItem: string | null;
toggle: (id: string) => void;
getResolvedId: (item: T, index: number) => string;
getButtonRef: (index: number) => RefCallback<HTMLButtonElement>;
handleKeyDown: (e: KeyboardEvent<HTMLButtonElement>, index: number) => void;
};
export {};