@typography-org/native
v1.0.0
Published
A library for calculating text elision that mimics browser behavior
Downloads
10
Maintainers
Readme
@typography-org/native
install
npm i @typography-org/native -S
fast use
normal example
import formatWithEllipsis from '@typography-org/native';
const width = 300;
const rows = 2;
const formatedText = formatWithEllipsis(props.children, {
length: width * rows,
lines: rows,
fontSize: 14,
fontFamily: '-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol',
});
recognize break lines
import formatWithEllipsis from '@typography-org/native';
const width = 300;
const rows = 2;
const formatedText = formatWithEllipsis(props.children, {
length: width * rows,
lines: rows,
fontSize: 14,
fontFamily: '-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol',
}, {
recognizeLineBreaks: true,
});
Documentation
See https://drdevelop.github.io/typography/native/index.html