Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Hyphenate text in React components

License

NotificationsYou must be signed in to change notification settings

sergeysolovev/react-hyphen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm versionCircleCI

Hyphenate text in React components. Based on thehyphenated library.

  • Simple API: wrap your components withHyphenated to hyphenate all nestedelements.
  • Multiple languages: use any language fromhyphenated.

View demo →

Quickstart

Install from the command line:

npm install react-hyphen

This installation will include hyphenation patterns for the American Englishlanguage as a dependency.

Wrap your components withHyphenated, so they will be rendered with softhyphens:

importReactfrom'react';importHyphenatedfrom'react-hyphen';constHyphenatedText=()=>(<Hyphenated>    From Ambrose Bierce’s<em>Devil’s Dictionary</em>:<section><p><strong>Self-evident</strong>,<em>adj.</em> Evident to one’s self and        to nobody else.</p></section></Hyphenated>);

Soft hyphens are invisible but they tell the browser where to put real visiblehyphens.

Multilingual text

By default,Hyphenated uses hyphenation patterns for the American Englishlanguage. To hyphenate text in another language, import necessary languages fromhyphenatedand pass as alanguage prop:

importReactfrom'react';importHyphenatedfrom'react-hyphen';importfrfrom'hyphenated-fr';importdefrom'hyphenated-de';constMultilingualText=()=>(<Hyphenated>    It is possible to hyphenate multilingual text.{' '}<Hyphenatedlanguage={fr}>      Je suis l{"'"}itinéraire donné par Pierre, un ami français.</Hyphenated>{' '}<Hyphenatedlanguage={de}>      Das Universalgenie war nicht nur Schriftsteller, sondern auch      Rechtsanwalt.</Hyphenated>{' '}    Just wrap it using an appropriate language.</Hyphenated>);

The resulting text will include optional hyphens using patterns for AmericanEnglish, French and German languages.

License

MIT

About

Hyphenate text in React components

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp