react-fitter
Version:
<h1 align="center">🫸 𝚛𝚎𝚊𝚌𝚝-𝚏𝚒𝚝𝚝𝚎𝚛 🫷</h1>
46 lines (43 loc) • 1.74 kB
text/typescript
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode } from 'react';
type FitterProps = {
/**
* The content to fit.
*/
children: ReactNode;
/**
* The minimum scale that the text will shrink to. E.g. 0.25 means the text
* will shrink to no less than 25% of its original size.
*/
minSize?: number;
/**
* The maximum number of lines that the text will shrink to fit.
*/
maxLines?: number;
/**
* The precision at which the text will settle. The component finds the best
* size by halving the difference between the current size and the min/max
* size. If the difference is less than the settle precision, the component
* will stop and settle on that size. A value of 0.01 means the component will
* settle when the difference is less than 1%.
*/
settlePrecision?: number;
/**
* Whether to update the text size when the size of the component changes.
*/
updateOnSizeChange?: boolean;
/**
* The time in milliseconds to wait before updating the text size when the
* size of the component changes. This is useful when the component is being
* resized frequently and you want to avoid updating the text size on every
* resize event.
*/
resizeDebounceMs?: number;
};
/**
* A utility component that fits text to a container by finding the best text
* size through binary search. The text will never grow larger than the original
* size and will shrink to fit the container.
*/
declare const Fitter: ({ children, minSize, maxLines, settlePrecision, updateOnSizeChange, resizeDebounceMs, }: FitterProps) => react_jsx_runtime.JSX.Element;
export { Fitter, type FitterProps };