UNPKG

@carbon/react

Version:

React components for the Carbon Design System

41 lines (39 loc) 1.42 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 { deprecate } from "../../prop-types/deprecate.js"; import { forwardRef } from "react"; import PropTypes from "prop-types"; import { jsx } from "react/jsx-runtime"; //#region src/components/UIShell/Link.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 Link = forwardRef((props, ref) => { const { element, as: BaseComponent, isSideNavExpanded: _isSideNavExpanded, ...rest } = props; return /* @__PURE__ */ jsx(BaseComponent ?? element ?? "a", { ref, ...rest }); }); /** * Link is a custom component that allows us to supporting rendering elements * other than `a` in our markup. The goal is to allow users to support passing * in their own components to support use-cases like `react-router` or * `@reach/router` */ const LinkPropTypes = { as: PropTypes.elementType, element: deprecate(PropTypes.elementType, "The `element` prop for `Link` has been deprecated. Please use `as` instead. This will be removed in the next major release."), isSideNavExpanded: PropTypes.bool }; Link.displayName = "Link"; Link.propTypes = LinkPropTypes; //#endregion export { LinkPropTypes, Link as default };