@base-ui-components/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.
67 lines (66 loc) • 2.46 kB
TypeScript
import * as React from 'react';
export declare function useAccordionRoot(parameters: useAccordionRoot.Parameters): useAccordionRoot.ReturnValue;
export type AccordionValue = (any | null)[];
type Direction = 'ltr' | 'rtl';
export type AccordionOrientation = 'horizontal' | 'vertical';
export declare namespace useAccordionRoot {
interface Parameters {
/**
* The controlled value of the item(s) that should be expanded.
*
* To render an uncontrolled accordion, use the `defaultValue` prop instead.
*/
value?: AccordionValue;
/**
* The uncontrolled value of the item(s) that should be initially expanded.
*
* To render a controlled accordion, use the `value` prop instead.
*/
defaultValue?: AccordionValue;
/**
* Whether the component should ignore user interaction.
* @default false
*/
disabled: boolean;
direction: Direction;
/**
* Whether to loop keyboard focus back to the first item
* when the end of the list is reached while using the arrow keys.
* @default true
*/
loop: boolean;
/**
* Event handler called when an accordion item is expanded or collapsed.
* Provides the new value as an argument.
*/
onValueChange: (value: AccordionValue) => void;
/**
* Whether multiple items can be open at the same time.
* @default true
*/
openMultiple: boolean;
/**
* The visual orientation of the accordion.
* Controls whether roving focus uses left/right or up/down arrow keys.
* @default 'vertical'
*/
orientation: AccordionOrientation;
}
interface ReturnValue {
getRootProps: (externalProps?: React.ComponentPropsWithRef<'div'>) => React.ComponentPropsWithRef<'div'>;
accordionItemRefs: React.RefObject<(HTMLElement | null)[]>;
direction: Direction;
/**
* Whether the component should ignore user interaction.
*/
disabled: boolean;
handleValueChange: (value: number | string, nextOpen: boolean) => void;
orientation: AccordionOrientation;
/**
* The open state of the Accordion represented by an array of the values
* of all open `<Accordion.item/>`s
*/
value: AccordionValue;
}
}
export {};