UNPKG

@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.

78 lines 2.71 kB
import * as React from 'react'; import { BaseUIComponentProps, Orientation } from "../../utils/types.js"; import { type BaseUIChangeEventDetails } from "../../utils/createBaseUIEventDetails.js"; /** * Groups all parts of the accordion. * Renders a `<div>` element. * * Documentation: [Base UI Accordion](https://base-ui.com/react/components/accordion) */ export declare const AccordionRoot: React.ForwardRefExoticComponent<AccordionRoot.Props & React.RefAttributes<HTMLDivElement>>; export type AccordionValue = (any | null)[]; export declare namespace AccordionRoot { interface State { value: AccordionValue; /** * Whether the component should ignore user interaction. */ disabled: boolean; orientation: Orientation; } interface Props extends BaseUIComponentProps<'div', State> { /** * 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; /** * Allows the browser’s built-in page search to find and expand the panel contents. * * Overrides the `keepMounted` prop and uses `hidden="until-found"` * to hide the element without removing it from the DOM. * @default false */ hiddenUntilFound?: boolean; /** * Whether to keep the element in the DOM while the panel is closed. * This prop is ignored when `hiddenUntilFound` is used. * @default false */ keepMounted?: boolean; /** * 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, eventDetails: ChangeEventDetails) => void; /** * Whether multiple items can be open at the same time. * @default true */ multiple?: boolean; /** * The visual orientation of the accordion. * Controls whether roving focus uses left/right or up/down arrow keys. * @default 'vertical' */ orientation?: Orientation; } type ChangeEventReason = 'trigger-press' | 'none'; type ChangeEventDetails = BaseUIChangeEventDetails<ChangeEventReason>; }