1.1.4 • Published 5 months ago

react-truncated-chips v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

react-truncated-chips

A headless component to implement a truncated chips based on parent container/screen size for users! Small bundle size of 2.1kb but can create super powerful UI experiences with a simple-to-use API.
npm.io

The problem

You need to truncate overflowing react elements (e.g. chips) based on the parent container/screen size. You've tried overflow: hidden, but you need to render an overflow indicator. You toy around with state, but it quickly gets complex. You want a simple solution that works out of the box.

This solution

This library offers a headless component that handles all of the logic for you. It's as simple as wrapping your children components with the TruncatedChipGroup component. It will automatically help you calculate how many elements can be shown in the given space! You can also render the children in reverse order if that's your thing!

Some similar solutions exist to achieve similar UI behaviour, but I couldn't find one that fit all of my needs. Here are several components that inspired this that you may want to check out as well:

Features:

✅ reverse rendering children
✅ works with any react elements that accept a ref
✅ custom overflow indicator
✅ custom spacing between children components
✅ responsive to parent container/screen size
✅ small bundle size 2.1kb (minified + gzipped)

Install

  npm install --save react-truncated-chips

  or

  yarn add react-truncated-chips

Documentation

Please see our storybook here

1.1.1

5 months ago

1.1.4

5 months ago

1.1.3

5 months ago

1.1.2

5 months ago

1.1.0

5 months ago