Giter Club home page Giter Club logo

react-virtuoso's Introduction

npm version

React Virtuoso is a simple, easy to use React virtualized list component that can render huge data sets. Out of the box, Virtuoso:

  • Handles items with variable dynamic height; no manual measurements or hard-coding of item heights necessary;
  • Supports grouping with sticky group headers (GroupedVirtuoso);
  • Supports responsive grid layout (VirtuosoGrid);
  • Automatically handles content resizing;
  • Can render footer at the end of the list;
  • Can pin the first N items to the top of the list.

For live examples and documentation, check the website.

Get Started

Install the package in your React project:

npm install react-virtuoso

Or, if yarn is your thing:

yarn add react-virtuoso

Then, put the component somewhere in your tree:

import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { Virtuoso } from 'react-virtuoso'

const App = () => {
  return (
    <Virtuoso style={{ width: '200px', height: '400px' }} totalCount={200} item={index => <div>Item {index}</div>} />
  )
}

ReactDOM.render(<App />, document.getElementById('root'))

Grouping

The GroupedVirtuoso component is similar to the "flat" Virtuoso, with the following differences:

  • Instead of totalCount, the component accepts groupCounts: number[], which specifies the amount of items in each group. For example, passing [20, 30] will render two groups with 20 and 30 items each;
  • In addition the item render prop, the component requires an additional group render prop, which renders the group header. The group callback receives the zero-based group index as a parameter;
  • The item render prop gets called with an additional second parameter, groupIndex: number.

Check the grouped numbers, grouped by first letter and groups with load on demand examples.

Grid

The VirtuosoGrid component displays same sized items in multiple columns. The layout and item sizing is controlled through CSS class properties, which allows you to use media queries, min-width, percentage, etc.

Check the responsive grid columns example for a sample implementation.

Footer

The component accepts an optional footer render property, which is rendered after all items. The footer can be used to host a "load more" button or an indicator that the user has reached the end of the list.

Check the footer, press load more and endless scrolling examples for practical applications of the footer.

Pinned Items

The component accepts an optional topItems property, that specifies how many of the items to keep "pinned" at the top of the list. Check the top items example.

Documentation and Demos

For in-depth documentation and live examples of the supported features and live demos, check the website.

Author

Petyo Ivanov @petyosi

License

MIT License.

react-virtuoso's People

Contributors

adipascu avatar dependabot[bot] avatar fezvrasta avatar jiggum avatar jmeistrich avatar johanneslumpe avatar joshacheson avatar leroydev avatar lesha1201 avatar mohtada-h avatar pedroalves0 avatar petyosi avatar toonvd avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.