diff --git a/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx b/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx index 153ca479..fab4ec69 100644 --- a/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx +++ b/packages/coreui-react/src/components/breadcrumb/CBreadcrumbItem.tsx @@ -1,14 +1,22 @@ -import React, { forwardRef, HTMLAttributes } from 'react' +import React, { ElementType, forwardRef, HTMLAttributes } from 'react' import PropTypes from 'prop-types' import classNames from 'classnames' import { CLink } from '../link/CLink' +import { PolymorphicRefForwardingComponent } from '../../helpers' + export interface CBreadcrumbItemProps extends HTMLAttributes { /** * Toggle the active state for the component. */ active?: boolean + /** + * Component used for the root node. Either a string to use a HTML element or a component. + * + * @since 5.4.0 + */ + as?: ElementType /** * A string of all className you want applied to the base component. */ @@ -19,26 +27,33 @@ export interface CBreadcrumbItemProps extends HTMLAttributes { href?: string } -export const CBreadcrumbItem = forwardRef( - ({ children, active, className, href, ...rest }, ref) => { - return ( -
  • - {href ? {children} : children} -
  • - ) - }, -) +export const CBreadcrumbItem: PolymorphicRefForwardingComponent<'li', CBreadcrumbItemProps> = + forwardRef( + ({ children, active, as, className, href, ...rest }, ref) => { + return ( +
  • + {href ? ( + + {children} + + ) : ( + children + )} +
  • + ) + }, + ) CBreadcrumbItem.propTypes = { active: PropTypes.bool, diff --git a/packages/docs/content/api/CBreadcrumbItem.api.mdx b/packages/docs/content/api/CBreadcrumbItem.api.mdx index 431f6fb3..e3b91512 100644 --- a/packages/docs/content/api/CBreadcrumbItem.api.mdx +++ b/packages/docs/content/api/CBreadcrumbItem.api.mdx @@ -8,5 +8,6 @@ import CBreadcrumbItem from '@coreui/react/src/components/breadcrumb/CBreadcrumb | Property | Description | Type | Default | | --- | --- | --- | --- | | **active** | Toggle the active state for the component. | `boolean` | - | +| **as** **_5.4.0+_** | Component used for the root node. Either a string to use a HTML element or a component. | `(ElementType & 'symbol')` \| `(ElementType & 'object')` \| `(ElementType & 'li')` \| `(ElementType & 'slot')` \| `(ElementType & 'style')` \| `... 174 more ...` \| `(ElementType & FunctionComponent<...>)` | - | | **className** | A string of all className you want applied to the base component. | `string` | - | | **href** | The `href` attribute for the inner `` component. | `string` | - |