@carbon/react
Version:
React components for the Carbon Design System
53 lines (51 loc) • 1.57 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { usePrefix } from "../../internal/usePrefix.js";
import { AccordionProvider } from "./AccordionProvider.js";
import classNames from "classnames";
import "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/Accordion/Accordion.tsx
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
function Accordion({ align = "end", children, className: customClassName, disabled = false, isFlush = false, ordered = false, size, ...rest }) {
const prefix = usePrefix();
const className = classNames(`${prefix}--accordion`, customClassName, {
[`${prefix}--accordion--${align}`]: align,
[`${prefix}--accordion--${size}`]: size,
[`${prefix}--layout--size-${size}`]: size,
[`${prefix}--accordion--flush`]: isFlush && align !== "start"
});
return /* @__PURE__ */ jsx(AccordionProvider, {
disabled,
children: /* @__PURE__ */ jsx(ordered ? "ol" : "ul", {
className,
...rest,
children
})
});
}
Accordion.propTypes = {
align: PropTypes.oneOf(["start", "end"]),
children: PropTypes.node,
className: PropTypes.string,
disabled: PropTypes.bool,
isFlush: PropTypes.bool,
ordered: PropTypes.bool,
size: PropTypes.oneOf([
"sm",
"md",
"lg"
])
};
//#endregion
export { Accordion as default };