UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

36 lines (35 loc) 1.04 kB
import * as React from 'react'; import type { PolymorphicForwardRefComponent } from '../props.js'; type MiddleTextTruncationProps = { /** * Text to truncate. */ text: string; /** * Number of characters to leave at the end. * @default 6 */ endCharsCount?: number; /** * Custom renderer for the truncated text. */ textRenderer?: (truncatedText: string, originalText: string) => React.ReactNode; }; /** * Truncates text with the ellipsis in the middle, * leaving defined number of chars at the end. * @example * <MiddleTextTruncation text='ThisIsMyVeryLongFileName.dgn' /> * @example * <MiddleTextTruncation text='ThisIsMyVeryLongFileName.dgn' endCharsCount={10} /> * @example * <MiddleTextTruncation * text='ThisIsMyVeryLongFileName.dgn' * textRenderer={React.useCallback( * (truncatedText) => <b>{truncatedText}</b>, * [] * )} * /> */ export declare const MiddleTextTruncation: PolymorphicForwardRefComponent<"span", MiddleTextTruncationProps>; export {};