UNPKG

962 BJavaScriptView Raw
1import React from 'react';
2import PropTypes from 'prop-types';
3import classNames from 'classnames';
4import { mapToCssModules, tagPropType } from './utils';
5
6const propTypes = {
7 /** Adds a visual "active" state to a Breadcrumb Item */
8 active: PropTypes.bool,
9 /** Add custom class to the element */
10 className: PropTypes.string,
11 /** Change existing className with a new className */
12 cssModule: PropTypes.object,
13 /** Set a custom element for this component */
14 tag: tagPropType,
15};
16
17function BreadcrumbItem(props) {
18 const {
19 className,
20 cssModule,
21 active,
22 tag: Tag = 'li',
23 ...attributes
24 } = props;
25 const classes = mapToCssModules(
26 classNames(className, active ? 'active' : false, 'breadcrumb-item'),
27 cssModule,
28 );
29
30 return (
31 <Tag
32 {...attributes}
33 className={classes}
34 aria-current={active ? 'page' : undefined}
35 />
36 );
37}
38
39BreadcrumbItem.propTypes = propTypes;
40
41export default BreadcrumbItem;