UNPKG

use-truncate-from-middle

Version:

React hook which dynamically calculates the maximum number of characters that fit into an HTML element and truncates the text from middle with given middle chars.

13 lines (12 loc) 372 B
import { Target } from '../utils/getTargetElement'; interface Options { ref: Target; originalText: string; middleChars?: string; } declare const useTruncateFromMiddle: ({ ref, originalText, middleChars }: Options) => { truncatedText: string; contentWidth: number; textWidth: number | undefined; }; export default useTruncateFromMiddle;