@carbon/react
Version:
React components for the Carbon Design System
32 lines (30 loc) • 999 B
JavaScript
/**
* 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 classNames from "classnames";
import { forwardRef } from "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
const BadgeIndicator = forwardRef((props, ref) => {
const { className: customClassName, count, ...rest } = props;
const prefix = usePrefix();
const classNames$1 = classNames(`${prefix}--badge-indicator`, customClassName, { [`${prefix}--badge-indicator--count`]: count });
const displayCount = count && count > 999 ? "999+" : count;
return /* @__PURE__ */ jsx("div", {
className: classNames$1,
ref,
...rest,
children: displayCount
});
});
BadgeIndicator.propTypes = {
className: PropTypes.string,
count: PropTypes.number,
id: PropTypes.string
};
//#endregion
export { BadgeIndicator as default };