@primer/react
Version:
An implementation of GitHub's Primer Design System using React
40 lines (37 loc) • 952 B
JavaScript
import React from 'react';
import { clsx } from 'clsx';
import { BoxWithFallback } from '../internal/components/BoxWithFallback.js';
import classes from './Truncate.module.css.js';
import { jsx } from 'react/jsx-runtime';
const Truncate = /*#__PURE__*/React.forwardRef(function Truncate({
as,
children,
className,
title,
inline,
expandable,
maxWidth = 125,
style,
sx,
...rest
}, ref) {
return /*#__PURE__*/jsx(BoxWithFallback, {
...rest,
ref: ref,
as: as,
className: clsx(className, classes.Truncate),
"data-expandable": expandable,
"data-inline": inline,
title: title,
style: {
...style,
[`--truncate-max-width`]: typeof maxWidth === 'number' ? `${maxWidth}px` : typeof maxWidth === 'string' ? maxWidth : undefined
},
sx: sx,
children: children
});
});
if (process.env.NODE_ENV !== "production") {
Truncate.displayName = 'Truncate';
}
export { Truncate as default };