@carbon/react
Version:
React components for the Carbon Design System
41 lines (39 loc) • 1.39 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 { SideNavContext, SideNavContextProvider } from "./SideNavContext.js";
import classNames from "classnames";
import { useContext } from "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/UIShell/SideNavItems.tsx
/**
* 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.
*/
const SideNavItems = ({ className: customClassName, children, isSideNavExpanded }) => {
const prefix = usePrefix();
const { isRail, isSideNavExpanded: contextIsSideNavExpanded } = useContext(SideNavContext);
return /* @__PURE__ */ jsx(SideNavContextProvider, {
isRail,
isSideNavExpanded: isSideNavExpanded ?? contextIsSideNavExpanded,
children: /* @__PURE__ */ jsx("ul", {
className: classNames([`${prefix}--side-nav__items`], customClassName),
children
})
});
};
SideNavItems.displayName = "SideNavItems";
SideNavItems.propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
isSideNavExpanded: PropTypes.bool
};
//#endregion
export { SideNavItems as default };