UNPKG

@carbon/react

Version:

React components for the Carbon Design System

50 lines (48 loc) 1.58 kB
/** * 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 Link from "./Link.js"; import SideNavLinkText from "./SideNavLinkText.js"; import classNames from "classnames"; import { forwardRef } from "react"; import PropTypes from "prop-types"; import { jsx } from "react/jsx-runtime"; //#region src/components/UIShell/SideNavMenuItem.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 SideNavMenuItem = forwardRef((props, ref) => { const prefix = usePrefix(); const { children, className: customClassName, as: Component = Link, isActive, ...rest } = props; const className = classNames(`${prefix}--side-nav__menu-item`, customClassName); const linkClassName = classNames({ [`${prefix}--side-nav__link`]: true, [`${prefix}--side-nav__link--current`]: isActive }); return /* @__PURE__ */ jsx("li", { className, children: /* @__PURE__ */ jsx(Component, { ...rest, className: linkClassName, ref, children: /* @__PURE__ */ jsx(SideNavLinkText, { children }) }) }); }); SideNavMenuItem.displayName = "SideNavMenuItem"; SideNavMenuItem.propTypes = { as: PropTypes.elementType, children: PropTypes.node, className: PropTypes.string, href: PropTypes.string, isActive: PropTypes.bool }; //#endregion export { SideNavMenuItem as default };