@foxeian/react-read-more

中文文档
1.1.5发布于 2024/09/17MITTypeScriptESM + CJS零依赖近 30 天下载 2823

A React.js package for creating short text with a "read more" button to expand the text, built with TypeScript support. This package provides a simple and easy-to-use component for truncating and expanding text with a customizable button.

原始使用文档
文档目录8 节
  1. About
  2. Features
  3. Getting Started
  4. Installation
  5. Quickstart
  6. Example of 'ReadMoreArea' customize
  7. Parameters
  8. License

Foxeian Logo

React Read More

ScreenGIF

Quickstart | Installation | Examples | Parameters

About

React Read More A React.js package for creating short text with a "read more" button to expand the text, built with TypeScript support. This package provides a simple and easy-to-use component for truncating and expanding text with a customizable button.

Features

  • Support Typescript
  • Every part of component (container, text, button) is customizable
  • It works with Server-side components (SSR)
  • Support classes (Tailwind, Bootstrap, etc...)
  • Easy-to-use

Getting Started

Installation

To install the package:

npm install @foxeian/react-read-more

Quickstart

example of 'ReadMoreArea' in React Component

import React from 'react';
import ReadMoreArea from '@foxeian/react-read-more';

export default function App() {
  return (
    <ReadMoreArea
      lettersLimit={100} // limit of letters (100 letters)
    >
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </ReadMoreArea>
  );
}
);

Example of 'ReadMoreArea' customize

import React from 'react';
import ReadMoreArea from '@foxeian/react-read-more';

const buttonStyle = {
  color: "blue",
  fontSize: "1rem",
  padding: "1.5rem",
  // Add any other CSS styles as needed
};

export default function App() {
  return (
    <ReadMoreArea
      className="flex flex-col" // classes styles of main div (tailwind)
      style={{ display: 'flex', flexDirection: 'column' }} // inline styles of main div
      expandLabel="Read more" // Expand Label
      collapseLabel="Read less" // Collapse Label
      textClassName="text-lg text-black" // classes styles of text (tailwind)
      textStyle={{ fontSize: '1rem', color: 'black' }} // inline styles of text
      buttonClassName="text-base text-green-700 p-6" // classes styles of button (tailwind)
      buttonStyle={buttonStyle} // inline styles of button
      lettersLimit={100} // limit of letters (100 letters)
    >
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </ReadMoreArea>
  );
}
);

Parameters

NameDescriptionTypeDefault value
classNameclasses styles of main divstringnull
styleinline styles of main divCSS Propertiesnull
expandLabelExpand LabelnumberRead more
collapseLabelCollapse LabelstringRead less
textClassNameclasses styles of textstringnull
textStyleinline styles of textCSS Propertiesnull
buttonClassNameclasses styles of buttonstringnull
buttonStyleinline styles of buttonCSS Propertiesnull
lettersLimitlimit of lettersnumber500

License

MIT © Immanuel Ehsan

版本与发布记录

@foxeian/react-read-more 共发布 8 个版本,首次发布于 2024/03/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.5latest2024/09/172 年前
1.1.22024/05/052 年前
1.1.12024/03/152 年前
1.0.92024/03/132 年前
1.0.82024/03/132 年前
1.0.72024/03/132 年前

关于 @foxeian/react-read-more 的常见问题

@foxeian/react-read-more 是什么?

A React.js package for creating short text with a "read more" button to expand the text, built with TypeScript support. This package provides a simple and easy-to-use component for truncating and expanding text with a customizable button.

如何安装 @foxeian/react-read-more?

在项目目录运行 npm install @foxeian/react-read-more,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>= 17.0.0)、react-dom(>= 17.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@foxeian/react-read-more 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@foxeian/react-read-more 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@foxeian/react-read-more 可以商用吗?

@foxeian/react-read-more 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@foxeian/react-read-more 的下载量有多少?

根据 npm 官方下载统计,@foxeian/react-read-more 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,823 次,日均约 94 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@foxeian/react-read-more 还在维护吗?

最新版本 1.1.5 发布于 2024/09/17(2 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/03/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。