@carusox/hyphenator
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Hyphenator

Hyphenation does not correctly work in all devices and browsers. This library will let you hyphenate text via JS. Hyphenation provided by this library is far from perfect, but good enough for most usecases.

For now we provide a single hook called useSoftHyphenation.

This hook will only add hyphens to words than don't fit the viewport, since our target are really long words (probably autogenerated or something). It will also recalculate the correct hyphens when the element resizes. Keep in mind this does hyphenates anywhere on the word.

This hook receives the reference of the element, and the text that you want to display in it.

You can see it in action in this codesandbox.

We also provide SoftHyphenatedText which is a simple span that uses the hook explained before.

Dependencies (0)

    Dev Dependencies (8)

    Package Sidebar

    Install

    npm i @carusox/hyphenator

    Weekly Downloads

    1

    Version

    1.0.4

    License

    ISC

    Unpacked Size

    11 kB

    Total Files

    16

    Last publish

    Collaborators

    • carusox