1.1.1 • Published 5 years ago

react-word-splitter v1.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

React-Word-Splitter

This module is React/Next Component, which makes words splitted by word or char with span tag and specific attribute.

Installation

This module is available as an npm package.

// with npm
npm install react-word-splitter

// with yarn
yarn add react-word-splitter

Usage

Here is a quick example to get you started, it's all you need:

import React from "react";

import Splitter from "react-word-splitter";

export default function(){
    return(
        <Splitter
            rule="chars"
            eachClass="testClass"
            eachIdWithIndex="testID"
            indexOption="number"
            words="あいうえお"
        /> // <span class='testClass' id='testID__1'>あ</span><span class='testClass' id='testID__2'>い</span><span class='testClass' id='testID__3'>う</span><span class='testClass' id='testID__4'>え</span><span class='testClass' id='testID__5'>お</span>
    )
}

If you want to know in detail, Please check API set below.

API

Propertytypedetail
rule"words" | "chars"set split option
eachClassstringset common class each element has
eachIdWithIndexstringset ID each element has with Index
indexOption"number" | string[]set option about index
wordsstringwords which you want to split