npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-lorem-ipsum

v1.4.10

Published

React Component and Function for Creating Lorem Ipsum Text as Placeholder

Downloads

32,052

Readme

React Lorem Ipsum

React Lorem Ipsum is a (TypeScript-supported) React library including components and functions to generate placeholder text.

DEMO & USAGE

USAGE IN A LOREM IPSUM GENERATOR

When you develop a mockup page or backend API is not ready for data fetching and you have to make Frontend Development with static data until it comes, react-lorem-ipsum will create your gibberish texts for you.

In addition to Lorem Ipsum text, you can generate random avatars, names, surnames, full names and usernames to fill the fields about users randomly.

👍 React Lorem Ipsum is a zero-dependency, easy-to-use package.

NPM version NPM download Build

Table of Contents

  1. Install
  2. Demo
  3. How to Import
  4. Props
  5. Examples
  6. License
  7. Author

Install

react-lorem-ipsum

npm install react-lorem-ipsum

or

yarn add react-lorem-ipsum

Demo

https://fatihtelis.github.io/react-lorem-ipsum

How to Import

Components

import { LoremIpsum, Avatar } from 'react-lorem-ipsum';

Functions

import { loremIpsum, name, surname, fullname, username } from 'react-lorem-ipsum';

Props

LoremIpsum (Component), loremIpsum (function)

loremIpsum is function version of the component LoremIpsum which generates plain text instead of HTML. They both get the same props/inputs as a single object.

| Name | Type | Default | Description | | ------------------------ | ------ | ------- | ----------------------------------------------------------------------------------------- | | p | number | 1 | Number of paragraphs that will be generated | | avgWordsPerSentence | number | 8 | Avarage number of words created for each sentence (standard deviation is fixed ±25%) | | avgSentencesPerParagraph | number | 8 | Avarage number of sentences created for each paragraph (standard deviation is fixed ±25%) | | startWithLoremIpsum | bool | true | Start with 'Lorem ipsum odor amet...' to first sentence of first paragraph | | random | bool | true | If disabled always generates the same text |

Note: If you use loremIpsum function to generate plain text, it will return an "Array" with length of the desired count. You can use "Array.map" or similar methods to process the data. See Examples for details.

Avatar (Component)

| Name | Type | Default | Description | | ------ | ------ | ------- | ------------------------------------------------------------------------------------------ | | gender | string | 'all' | Gender for the Avatar picture. Possible values are 'all', 'male' and 'female'. |

Note: Avatar component returns an <img /> tag with a random image. All other props like "className, width, height, alt" etc. will directly passed to element.

name, fullname (Functions)

| Name | Type | Default | Description | | ------ | ------ | ------- | ------------------------------------------------------------------------------------------------------- | | gender | string | 'all' | Gender for the generated name or full name. Possible values are 'all', 'male' and 'female'. |

surname, username (Functions)

| Props | | ----------------------------------------------------------------------------------------------------------------------------- | | surname and username functions does not take any inputs. They just create random surnames and usernames respectively. |

Examples

LoremIpsum (Component)

Code

import React from 'react';
import { render } from 'react-dom';
import { LoremIpsum } from 'react-lorem-ipsum';

render(
  <div className="text-wrapper">
    <LoremIpsum p={2} />
  </div>,
  document.getElementById('root')
);

HTML Output

<div class="text-wrapper">
  <p>
    Lorem ipsum odor amet, consectetuer adipiscing elit. Ac purus in massa egestas mollis varius;
    dignissim elementum. Mollis tincidunt mattis hendrerit dolor eros enim, nisi ligula ornare.
    Hendrerit parturient habitant pharetra rutrum gravida porttitor eros feugiat. Mollis elit
    sodales taciti duis praesent id. Consequat urna vitae morbi nunc congue.
  </p>
  <p>
    Non etiam tempor id arcu magna ante eget. Nec per posuere cubilia cras porttitor condimentum
    orci suscipit. Leo maecenas in tristique, himenaeos elementum placerat. Taciti rutrum nostra,
    eget cursus velit ultricies. Quam molestie tellus himenaeos cubilia congue vivamus ultricies.
    Interdum praesent ut penatibus fames eros ad consectetur sed.
  </p>
</div>

loremIpsum (Function)

Code 1

import React from 'react';
import { render } from 'react-dom';
import { loremIpsum } from 'react-lorem-ipsum';

render(<div className="text-wrapper">{loremIpsum()}</div>, document.getElementById('root'));

HTML Output 1

<div class="text-wrapper">
  Lorem ipsum odor amet, consectetuer adipiscing elit. Imperdiet erat nullam tortor quis elit lacus
  blandit vitae. Nostra dapibus bibendum; curae magnis commodo metus vestibulum tristique. Tristique
  volutpat consectetur congue lorem pharetra habitant. Sodales gravida egestas venenatis dignissim
  molestie cursus porta. Massa lacus pulvinar aliquam mi tristique.
</div>

Code 2

import React from 'react';
import { render } from 'react-dom';
import { loremIpsum } from 'react-lorem-ipsum';

render(
  <div className="text-wrapper">
    {loremIpsum({ p: 3 }).map(text => (
      <div className="text" key={text}>
        {text}
      </div>
    ))}
  </div>,
  document.getElementById('root')
);

HTML Output 2

<div class="text-wrapper">
  <div class="text">
    Lorem ipsum odor amet, consectetuer adipiscing elit. Primis eros nunc fringilla id rutrum nibh.
    Orci convallis pulvinar urna fusce at purus neque nam leo? Suspendisse semper facilisi
    parturient sit euismod placerat. Orci ante luctus praesent torquent orci commodo aptent blandit.
    Placerat arcu dui potenti; nullam taciti taciti amet.
  </div>
  <div class="text">
    Ridiculus proin etiam justo vivamus dignissim suscipit maecenas. Gravida ornare interdum ex dui
    eu faucibus dictum dis blandit. Rhoncus habitasse suscipit felis massa, ultrices auctor. Laoreet
    magnis justo velit vulputate iaculis at pulvinar augue. Condimentum suspendisse habitasse metus
    cubilia curabitur non sem. Primis nam in nulla phasellus bibendum pretium.
  </div>
  <div class="text">
    Augue malesuada massa torquent diam tortor; porttitor dis massa. Habitasse nunc ad placerat;
    ante netus gravida a porttitor. Vel aliquet hendrerit efficitur facilisis fames lacinia porta
    per. Integer euismod aenean mi hendrerit in volutpat consequat tempus turpis. Bibendum massa ad
    tincidunt, platea montes ac arcu. Penatibus elit justo adipiscing magna vulputate leo per.
  </div>
</div>

Avatar, name, surname, fullname, username

Code 1

import React from 'react';
import { render } from 'react-dom';
import { name, surname, username } from 'react-lorem-ipsum';

render(
  <div className="user">
    // All props will be directly transferred to img element
    <Avatar gender="male" className="avatar" width="200" height="200" alt="Avatar" />
    <div className="name">{name('male')}</div>
    <div className="surname">{surname()}</div>
    <div className="username">{username()}</div>
  </div>,
  document.getElementById('root')
);

HTML Output 1

<div class="user">
  <img class="avatar" src="data:image/jpeg;base64,......" width="200" height="200" alt="Avatar" />
  <div class="name">John</div>
  <div class="surname">Smith</div>
  <div class="username">smart_guru</div>
</div>

Code 2

import React from 'react';
import { render } from 'react-dom';
import { fullname, username } from 'react-lorem-ipsum';

render(
  <div className="user">
    <div className="full-name">{fullname('female')}</div>
    <div className="username">{`@${username()}`}</div>
  </div>,
  document.getElementById('root')
);

HTML Output 2

<div class="user">
  <div class="full-name">Jennifer S. Rose</div>
  <div class="username">@smart.fox.19</div>
</div>

License

react-lorem-ipsum is released under the MIT license.

Author