Skip to content

CarusoX/Hyphenator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published