import React from 'react'; import type { ReactNode } from 'react'; import type { IconOrContent } from '../../util/utility-types'; import { type HeadingElement } from '../Heading'; type AccordionProps = { /** * Child node(s) that can be nested inside component. */ children: ReactNode; /** * Additional classnames passed in for styling. */ className?: string; /** * Used to specify which heading element should be rendered for each `Accordion.Title` child. * * **Default is `"h2"`**. */ headingAs: HeadingElement; }; type AccordionButtonProps = { /** * Child node(s) that can be nested inside component. */ children?: ReactNode; /** * Additional classnames passed in for styling */ className?: string; /** * Callback for when accordion is closed. */ onClose?: () => void; /** * Callback for when according is opened. */ onOpen?: () => void; /** * Used to specify which heading element should be rendered for the title. * If provided, overrides parent headingAs prop. */ headingAs?: HeadingElement; /** * Content that precedes the text in an accordion header. Pass an EDS icon name to render * a decorative icon, or a node to render it as-is. */ leadingContent?: IconOrContent; /** * Secondary text used to describe the content in more detail */ subTitle?: ReactNode; /** * The title/heading of the component */ title?: string; /** * Slot which follows the text in an accordion header */ trailingContent?: ReactNode; }; type AccordionPanelProps = { /** * Child node(s) that can be nested inside component. */ children: ReactNode; /** * Additional class names passed in for styling */ className?: string; }; type AccordionRowProps = { /** * Child node(s) that can be nested inside component. */ children: ReactNode | (({ open }: { open: boolean; }) => ReactNode); /** * Additional class names passed in for styling. */ className?: string; /** * Whether panel is expanded by default. */ defaultOpen?: boolean; /** * Whether the row can show expandable content */ isExpandable?: boolean; /** * Whether the row has content on the row's trigger that leads in front of the title */ hasLeadingContent?: boolean; /** * Whether the row has a content on the row's trigger that trails the title */ hasTrailingContent?: boolean; }; /** * ## Usage * * * **Reducing visual clutter**: Especially when dealing with long pages or dense content. * * **FAQs**: Users can click to reveal answers one at a time. * * **Grouped settings**: Like categories of options or configuration panels. * * | Type/Use | Description | Example | * |----------|-------------|---------| * |Standard|Expands/collapses content vertically when clicked.|FAQs. Lists with optional detail. Simple disclosure sections.| * |Multi-expand|Allows multiple sections to be expanded at once.|Filter panels. Settings grouped by category. Multi-topic summaries.| * |Single-Expand|Only one section can be open at a time (others collapse automatically).|Navigation menus. Step-by-step instructions. Content prioritization.| * |Nested|Accordion items contain sub-accordions inside.|Complex data views. Multi-level navigation or documentation.| * |Summary|Shows a brief summary even when collapsed.|Preview content like stats or status. Highlight key info without expanding.| * |Disabled|Cannot be expanded; often used to show unavailable or locked content.|Permissions-based content. Progress-dependent sections.| * * ### Best Practices * * * Don't mix accordions where some have icons and others do not. * * ## Interaction * * ### Collapsed and Expanded Rows * * By default, clicking another row does not collapse the row that has already been expanded. * Designers can customize this to only allow 1 accordion row to be open at a time. However, beware that this interaction can cause the UI to “jump around” in an unpleasant way. * * ## Content & Accessibility * * ### Do's * * * Order stacked accordions by priority and importance. * * Use short, descriptive text for the accordion title. * * Number the steps in the accordion section sequentially. * * Use paragraphs and subheads as needed within the accordion body. * * Use sentence case for titles. * * ### Don'ts * * * Don't use paragraphs of text in the accordion title. * * ## Resources * * * https://headlessui.com/react/disclosure */ export declare const Accordion: { ({ children, className, headingAs, ...other }: AccordionProps): React.JSX.Element; displayName: string; Button: { (props: AccordionButtonProps): React.JSX.Element; displayName: string; }; Panel: { ({ className, children, ...other }: AccordionPanelProps): React.JSX.Element; displayName: string; }; Row: { ({ className, defaultOpen, children, isExpandable, hasLeadingContent, hasTrailingContent, ...other }: AccordionRowProps): React.JSX.Element; displayName: string; }; }; export {};