2.2.0 • Published 6 months ago

react-auto-columns v2.2.0

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

📊 React Auto Columns

A React component that automatically arranges child elements into columns based on the available screen space, similar to the Discord GIF browser. This package is great for creating product listings, galleries, and more.

🚀 Demo

You can see the package in action on the demo website.

⚙️ Installation

npm install react-auto-columns

Or if you're using pnpm:

pnpm add react-auto-columns

🚀 Usage Example

import { Columns } from "react-auto-columns";
<Columns
  className="flex gap-4"
  columnClassName="flex flex-col gap-4 flex-1"
  columns={{ 1024: 2, 1280: 3 }}
>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
  <div>9</div>
  <div>10</div>
</Columns>

While the default value for the columns prop is 3, if no breakpoints match it will automatically use 1 column.

If you want to override this behavior, you can pass an object with a 0 key like this:

<Columns columns={{ 0:3, ... }}>
  ...
</Columns>

Props 🎛

Prop nameTypeDefault valueDescription
columnsnumber \| { [key: number]: number }3A fixed amount of columns or an object mapping breakpoints to column counts.
columnClassNamestring""Class name to apply to each column.

🤝 Contributing

Contributions to any of the packages are welcome!

If you have any questions, please reach out to me via Discord or email.

📝 License

All packages in this monorepo are licensed under the MIT License.

2.2.0

6 months ago

2.1.0

12 months ago

2.0.0

12 months ago

1.1.3

12 months ago

1.1.2

12 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago