Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/irene-24/react-truncatable

Streamline your UI with this React component that is designed to truncate text seamlessly. [Storybook Doc] https://64f883177ec11e1edcf84fc7-hpmuefbevq.chromatic.com/?path=/docs/stories-truncatable--docs
https://github.com/irene-24/react-truncatable

react storybook testing truncate-text

Last synced: about 1 month ago
JSON representation

Streamline your UI with this React component that is designed to truncate text seamlessly. [Storybook Doc] https://64f883177ec11e1edcf84fc7-hpmuefbevq.chromatic.com/?path=/docs/stories-truncatable--docs

Awesome Lists containing this project

README

        

# React Truncatable

[![NPM Publish](https://github.com/Irene-24/react-truncatable/actions/workflows/Build-deploy-npm.yaml/badge.svg)](https://github.com/Irene-24/react-truncatable/actions/workflows/Build-deploy-npm.yaml)

[![Deploy storybook via chromatic](https://github.com/Irene-24/react-truncatable/actions/workflows/Deploy-chromatic.yaml/badge.svg)](https://github.com/Irene-24/react-truncatable/actions/workflows/Deploy-chromatic.yaml)

## Overview

A React component that truncates text based on available space and supports multiline. Perfect for creating article previews, blog snippets, product card descriptions and many more.

Compatible with Next 13

## Install

It can be installed with npm, yarn or pnpm

### npm

```sh
npm install react-truncatable
```

### yarn

```sh
yarn add react-truncatable
```

### pnpm

```sh
pnpm install react-truncatable
```

### **Usage**

Include the css in `_app.(tsx|jsx|js)` or `index.(tsx|jsx|js)`or `app.(tsx|jsx|js)`, or whatever is the root jsx file.

```jsx
import "react-truncatable/style.css"
```

Include the import at the top, where the Truncatable will be used:

```jsx
import Truncatable from "react-truncatable";
```

and use like so

```jsx

```

You can also import the types, and use them if you need them (TS only)

```jsx

import Truncatable, { ToggleProps } from "react-truncatable";

const b: Omit = {
showAll: true,
toggle() {

},
};

console.log(b);

```

### **Help and Questions**

Raise an issue [here](https://github.com/Irene-24/react-truncatable/issues/new)

### **Support the project**

Don't forget to star the repository if it was helpful to you.