All Projects → sealninja → React Grid System

sealninja / React Grid System

Licence: mit
A powerful Bootstrap-like responsive grid system for React.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Grid System

React Virtualized
React components for efficiently rendering large lists and tabular data
Stars: ✭ 22,963 (+3720.8%)
Mutual labels:  grid
Lost
LostGrid is a powerful grid system built in PostCSS that works with any preprocessor and even vanilla CSS.
Stars: ✭ 4,506 (+649.75%)
Mutual labels:  grid
React Styled Flexboxgrid
Grid system based on styled-components and flexbox for React
Stars: ✭ 515 (-14.31%)
Mutual labels:  grid
React Redux Grid
A React Grid/Tree Component written in the Redux Pattern
Stars: ✭ 454 (-24.46%)
Mutual labels:  grid
Svelte Grid
A responsive, draggable and resizable grid layout, for Svelte.
Stars: ✭ 473 (-21.3%)
Mutual labels:  grid
Neat
Neat is maintained by the thoughtbot design team. It is funded by thoughtbot, inc. and the names and logos for thoughtbot are trademarks of thoughtbot, inc.
Stars: ✭ 4,506 (+649.75%)
Mutual labels:  grid
Gijgo
Gijgo - Free Javascript Controls
Stars: ✭ 424 (-29.45%)
Mutual labels:  grid
Styled Css Grid
🍱 A tiny CSS grid layout for React
Stars: ✭ 562 (-6.49%)
Mutual labels:  grid
Gridstack
A flexible grid layout view for SwiftUI
Stars: ✭ 474 (-21.13%)
Mutual labels:  grid
React Handsontable
React Data Grid with Spreadsheet Look & Feel. Official React wrapper for Handsontable.
Stars: ✭ 511 (-14.98%)
Mutual labels:  grid
Ngx Datatable
✨ A feature-rich yet lightweight data-table crafted for Angular
Stars: ✭ 4,415 (+634.61%)
Mutual labels:  grid
Waterfall.js
Tired of use creepy hacks or heavy ways to get a Grid based on Pinterest?
Stars: ✭ 458 (-23.79%)
Mutual labels:  grid
Appgrid
macOS window manager with Vim–like hotkeys
Stars: ✭ 500 (-16.81%)
Mutual labels:  grid
Apydatagridbundle
Symfony Datagrid Bundle
Stars: ✭ 452 (-24.79%)
Mutual labels:  grid
Horseshoe
🍧代号马蹄铁。以专题为单位的学习。目前已发布 { Async专题 } { Grid专题 } { Flex专题 } { Git专题 } { Regex专题 } { Redux专题 } { React专题 }
Stars: ✭ 521 (-13.31%)
Mutual labels:  grid
Nghandsontable
Official AngularJS directive for Handsontable
Stars: ✭ 438 (-27.12%)
Mutual labels:  grid
Vue Grid Layout
A draggable and resizable grid layout, for Vue.js.
Stars: ✭ 5,170 (+760.23%)
Mutual labels:  grid
Datatable
A simple, modern and interactive datatable library for the web
Stars: ✭ 587 (-2.33%)
Mutual labels:  grid
Reogrid
Fast and powerful .NET spreadsheet component, support data format, freeze, outline, formula calculation, chart, script execution and etc. Compatible with Excel 2007 (.xlsx) format and working on .NET 3.5 (or client profile), WPF and Android platform.
Stars: ✭ 532 (-11.48%)
Mutual labels:  grid
React Datasheet
Excel-like data grid (table) component for React
Stars: ✭ 4,866 (+709.65%)
Mutual labels:  grid

React Grid System

A powerful Bootstrap-like responsive grid system for React.

NPM version Downloads Dependency Status

⚠️ Upgrading to v7

react-grid-system v7 adds a new screen class xxl for very large screens. This might have consequences for your app. To opt out of this new screen class, use this:

import { setConfiguration } from 'react-grid-system';

setConfiguration({ maxScreenClass: 'xl' });

Installation

npm install react-grid-system --save

Getting started

Responsive grid

react-grid-system provides a responsive grid for React inspired by Bootstrap. Moreover, it has various additional powerful features, such as setting breakpoints and gutter widths through React's context.

Three components are provided for creating responsive grids: Container, Row, and Col.

An example on how to use these:

import { Container, Row, Col } from 'react-grid-system';

<Container>
  <Row>
    <Col sm={4}>
      One of three columns
    </Col>
    <Col sm={4}>
      One of three columns
    </Col>
    <Col sm={4}>
      One of three columns
    </Col>
  </Row>
</Container>

For all features of these components, please have a look at the API documentation: https://sealninja.github.io/react-grid-system/

Responsive utilities

Next to the grid, two components are provided for showing or hiding content: Visible and Hidden. The main difference between these two components and the similar CSS classes provided by Bootstrap is that these two components do not render the content at all when it should be hidden, instead of just hiding it with CSS.

Some examples on how to use these components:

import { Visible } from 'react-grid-system';

<p>
  <span>Your current screen class is </span>
  <Visible xs><strong>xs</strong></Visible>
  <Visible sm><strong>sm</strong></Visible>
  <Visible md><strong>md</strong></Visible>
  <Visible lg><strong>lg</strong></Visible>
  <Visible xl><strong>xl</strong></Visible>
  <Visible xxl><strong>xxl</strong></Visible>
  <span>.</span>
</p>
import { Visible, Hidden } from 'react-grid-system';

<Visible xs sm>
  <p>Paragraph visible on extra small and small.</p>
</Visible>
<Hidden xs sm>
  <p>Paragraph hidden on extra small and small.</p>
</Hidden>
<Visible md lg>
  <p>Paragraph visible on medium and large.</p>
</Visible>
<Hidden md lg>
  <p>Paragraph hidden on medium and large.</p>
</Hidden>

Next to that, the ScreenClassRender component is provided, for rendering a component differently based on the screen class. An example on how to use this:

import { ScreenClassRender } from 'react-grid-system';

<ScreenClassRender render={screenClass => (
  <p style={{ fontSize: ['lg', 'xl', 'xxl'].includes(screenClass) ? '2rem' : '1rem' }} >
    Screen class: {screenClass}
  </p>
)} />

Alternatively, the useScreenClass hook can be used for rendering a component differently based on the screen class. Some examples on how to use this:

import React from 'react';
import { useScreenClass } from 'react-grid-system';

// responsive component based the screen width
function Example1() {
  const screenClass = useScreenClass();
  return (
    <p style={{ fontSize: ['lg', 'xl', 'xxl'].includes(screenClass) ? '2rem' : '1rem' }} >
      Screen class: {screenClass}
    </p>
  );
}

// responsive component based the div width
function Example2() {
  const elementRef = useRef(null);
  const screenClass = useScreenClass(elementRef);
  return (
    <div ref={elementRef}>
      <p style={{ fontSize: ['lg', 'xl', 'xxl'].includes(screenClass) ? '2rem' : '1rem' }} >
        Screen class: {screenClass}
      </p>
    </div>
  );
}

Configuration

The following settings can be configured, to alter the responsive behavior of the grid components:

Setting Default Value Description
breakpoints [576, 768, 992, 1200, 1600] The breakpoints (minimum width) of devices in screen class sm, md, lg, xl, and xxl.
containerWidths [540, 740, 960, 1140, 1540] The container widths in pixels of devices in screen class sm, md, lg, xl, and xxl.
gutterWidth 30 The gutter width in pixels. A gutter width of 30 means 15px on each side of a column.
gridColumns 12 The number of columns in the grid .
defaultScreenClass xxl The screen class used when the view port cannot be determined using window.
maxScreenClass xxl The maximum screen class to be used.

These settings can be configured in the following way:

import { setConfiguration } from 'react-grid-system';

setConfiguration({ defaultScreenClass: 'sm', gridColumns: 20 });

An example on how to use them can be found in the Example application with SSR below.

ScreenClass Context API

Internally, every component that requires the current screenClass (which is a human-readable string version of the window.innerWidth relating to the user's breakpoints) subscribes to a ScreenClassProvider. The provider utilizes the React Context API to send down the current screenClass as it updates. By default, each instance of every component subscribes to a separate provider, creating resize listeners for each. This can cut down renders during a resize event from ~300 to 4 (one for each breakpoint) making the grid much more performant.

Do I need to change anything in my code?

This new API is entirely opt-in and current implementations will continue to work. However, for a signficiant performance increase, you will need to add the ScreenClassProvider to your application, typically at the highest level in the React node tree (i.e, App.js).

How do I use the ScreenClassProvider?

import React from 'react';
import { ScreenClassProvider } from 'react-grid-system';

export default function App() {
  return (
    <ScreenClassProvider>
      <Header />
      <Page />
      <Footer />
    </ScreenClassProvider>
  );
}

Internally, the ScreenClassProvider attaches a resize listener and then updates state.screenClass exclusively when a new breakpoint is hit. The state.screenClass value is then attached to ScreenClassContext.Provider. ScreenClass-dependent components are wrapped with ScreenClassResolver which checks to see if there is a valid provider above it and provides one if there is not.

The performance benefit comes from you adding a ScreenClassProvider to your application which allows react-grid-system components to subscribe to one source of truth for the ScreenClass.

API documentation

Extensive documentation of all components can be found at the GitHub pages: https://sealninja.github.io/react-grid-system/

Example application with SSR

An example application with server-side rendering using features of react-grid-system can be found at https://github.com/sealninja/react-ssr-example.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].