@carbon/react
Version:
React components for the Carbon Design System
52 lines (51 loc) • 1.93 kB
TypeScript
/**
* Copyright IBM Corp. 2016, 2025
*
* 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 PropTypes, { WeakValidationMap } from 'prop-types';
import { JSX, type ElementType } from 'react';
import { PolymorphicProps } from '../../types/common';
export interface LinkBaseProps {
/**
* @deprecated Use `as` instead
*/
element?: ElementType | undefined;
as?: ElementType | undefined;
isSideNavExpanded?: boolean | undefined;
}
export type LinkProps<E extends ElementType = 'a'> = PolymorphicProps<E, LinkBaseProps>;
export interface LinkComponent {
<E extends ElementType = 'a'>(props: LinkProps<E>): JSX.Element | null;
displayName?: string;
propTypes?: WeakValidationMap<LinkProps<any>>;
}
declare const Link: LinkComponent;
/**
* 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`
*/
declare const LinkPropTypes: {
/**
* Provide a custom element or component to render the top-level node for the
* component.
*/
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
/**
* The base element to use to build the link. Defaults to `a`, can also accept
* alternative tag names or custom components like `Link` from `react-router`.
* @deprecated Use `as` instead
*
*/
element: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
/**
* Property to indicate if the side nav container is open (or not). Use to
* keep local state and styling in step with the SideNav expansion state.
*/
isSideNavExpanded: PropTypes.Requireable<boolean>;
};
export { LinkPropTypes };
export default Link;