react-balanced-columns
v1.1.2
Published
Columns that self balance
Downloads
12
Readme
React Balanced Columns
Setup
Description
This component divides a list up into columns that "balance" themselves dynamically when both a max number of columns and min length to fill a column is specified.
Installation
Install using the package manager of your choice:
npm install react-balanced-columns
or yarn add react-balanced-columns
then include the component in your project:
import { BalancedColumns } from 'react-balanced-columns'
Props
| PropName | IsRequired | Type | Description | | ------------------ | ---------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | children | true | Array<React.Children> | This component accepts an array of react children that will be balanced across the rendered columns. | | minRowBreakpoint | true | number | The minimum number of rows that must be filled before proceeding to fill the next column. Note: given is a minimum each column may be longer than this length. | | maxColumns | true | number | The maximum number of columns allowed. Note: given this is a maximum, there may be fewer columns than this number. | | columnWidth | false | number | An optional field whose units are in pixels. It allows an exact width to be specified. The default is flex-basis auto, which will grow to accommodate width of the children. |
Examples
Below are some examples of how changing each of the props changes the end result.
Changing number of children
Changing maxColumns
Changing minRowBreakpoint
Contributing
Clone the project and run npm install
. npm run storybook
will spawn a staging ground to demo any changes to the component. Eslint and prettier are used for code formatting. TypeScript is used for the type-system and for transpilation to an es5 dist.