All Projects → roylee0704 → React Flexbox Grid

roylee0704 / React Flexbox Grid

A set of React components implementing flexboxgrid with the power of CSS Modules.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to React Flexbox Grid

React Atlas
Composable React components with CSS Modules.
Stars: ✭ 36 (-98.74%)
Mutual labels:  react-components, css-modules
React Cssom
Css selector for React Components
Stars: ✭ 57 (-98.01%)
Mutual labels:  react-components, css-modules
dash-flexbox-grid
Wrapper around react-flexbox-grid for Plotly Dash
Stars: ✭ 19 (-99.34%)
Mutual labels:  react-components, flexbox-grid
Jest-CSS-Modules
A Jest script processor that prevents CSS module parse errors.
Stars: ✭ 75 (-97.38%)
Mutual labels:  css-modules
shared-components
A shared React component library for Bandwidth UI projects
Stars: ✭ 19 (-99.34%)
Mutual labels:  react-components
react-gridforms
React components for Gridforms form layout
Stars: ✭ 29 (-98.99%)
Mutual labels:  react-components
React Weui
weui for react
Stars: ✭ 2,793 (-2.27%)
Mutual labels:  react-components
react-recurly
React components for Recurly.js
Stars: ✭ 38 (-98.67%)
Mutual labels:  react-components
reactsandbox
Create a React Component Sandboxes based on compositions
Stars: ✭ 11 (-99.62%)
Mutual labels:  react-components
typed-css-modules-loader
💠 Webpack loader for typed-css-modules auto-creation
Stars: ✭ 62 (-97.83%)
Mutual labels:  css-modules
11tyby
Simple 11ty setup using TypeScript, SASS, Preact with partial hydration, and other useful things. Aims to provide the DX of Gatsby, but using 11ty!
Stars: ✭ 38 (-98.67%)
Mutual labels:  css-modules
react-native-snippet
React Native, ReactJs, Redux, ES7 Snippet
Stars: ✭ 25 (-99.13%)
Mutual labels:  react-components
create-class-names
A utility to extend the values of a classNames object.
Stars: ✭ 16 (-99.44%)
Mutual labels:  css-modules
is-react
Determine if a variable or statement is a React element or component
Stars: ✭ 29 (-98.99%)
Mutual labels:  react-components
zeus
A novel mobile first flexbox BEM css grid.
Stars: ✭ 14 (-99.51%)
Mutual labels:  flexbox-grid
string-replace-to-array
Like Javascript's string.replace, but accepts and returns an array
Stars: ✭ 19 (-99.34%)
Mutual labels:  react-components
edgestack
[UNMAINTAINED] A Universal React Stack with deeply integrated localization Support, semi-automatic route-based code splitting, Hot Module Reloading (HMR), Redux, Apollo GraphQL and more...
Stars: ✭ 77 (-97.31%)
Mutual labels:  css-modules
components
Embed the power of Webex in your web applications, on your own terms 💪🏼
Stars: ✭ 15 (-99.48%)
Mutual labels:  react-components
isomorphic-relay-boilerplate
No description or website provided.
Stars: ✭ 30 (-98.95%)
Mutual labels:  css-modules
movies
Real world isomorphic application for movies search, based on Webpack 5 / Express / React 17 + Redux-Saga / Bootstrap 4.6 + CSS Modules / i18next / SSR
Stars: ✭ 20 (-99.3%)
Mutual labels:  css-modules

react-flexbox-grid

npm version Build Status NPM Status

react-flexbox-grid is a set of React components that implement flexboxgrid.css. It even has an optional support for CSS Modules with some extra configuration.

http://roylee0704.github.io/react-flexbox-grid/

Setup

Installation

react-flexbox-grid can be installed as an npm package:

npm install --save react-flexbox-grid

Minimal configuration

The recommended way to use react-flexbox-grid is with a tool like webpack or Meteor, make sure you set it up to support requiring CSS files. For example, the minimum required loader configuration for webpack would look like this:

{
  test: /\.css$/,
  loader: 'style-loader!css-loader',
  include: /flexboxgrid/
}

react-flexbox-grid imports the styles from flexboxgrid, that's why we're configuring the loader for it.

CSS Modules

If you want to use CSS Modules (this is mandatory for versions earlier than v1), webpack's css-loader supports this by passing modules param in the loader configuration.

First, install style-loader and css-loader as development dependencies:

npm install --save-dev style-loader css-loader

Next, add a loader for flexboxgrid with CSS Modules enabled:

{
  test: /\.css$/,
  loader: 'style-loader!css-loader?modules',
  include: /flexboxgrid/
}

Make sure you don't have another CSS loader which also affects flexboxgrid. In case you do, exclude flexboxgrid, for example:

{
  test: /\.css$/,
  loader: 'style-loader!css-loader!postcss-loader',
  include: path.join(__dirname, 'node_modules'), // oops, this also includes flexboxgrid
  exclude: /flexboxgrid/ // so we have to exclude it
}

Otherwise you would end up with an obscure error because webpack stacks loaders together, it doesn't override them.

Isomorphic support

Try: this comment.

If this doesn't work for you, use the build located in the dist directory. This build removes all .css imports and extracts the relevant css into react-flexbox-grid/dist/react-flexbox-grid.css.

Not using a bundler?

Use the pre-bundled build located in the dist directory. It contains a single umd js distributable and built css file.

Usage

Now you can import and use the components:

import React from 'react';
import { Grid, Row, Col } from 'react-flexbox-grid';

class App extends React.Component {
  render() {
    return (
      <Grid fluid>
        <Row>
          <Col xs={6} md={3}>
            Hello, world!
          </Col>
        </Row>
      </Grid>
    );
  }
}

Gotcha

For the time being always use fluid for <Grid> to prevent horizontal overflow issues.

Example

Looking for a complete example? Head over to react-flexbox-grid-example.

Advanced composition

We also export functions for generating Row and Column class names for use in other components.

For example, suppose you're using a third party component that accepts className and you would like it to be rendered as Col. You could do so by extracting the column sizing props that MyComponent uses and then pass the generated className on to SomeComponent

import React from 'react';
import { Row, Col, getRowProps, getColumnProps } from 'react-flexbox-grid';
// a component that accepts a className
import SomeComponent from 'some-package';

export default function MyComponent(props) {
  const colProps = getColumnProps(props);
  const rowProps = getRowProps(props);

  return (
    <form className={rowProps.className}>
      <SomeComponent classname={colProps.className} />
      <input value={props.value} onChange={props.onChange} />
    </form>
  );
}

MyComponent.propTypes = Object.assign({
  onChange: React.PropTypes.func.isRequired,
  value: React.PropTypes.string.isRequired,
}, Col.propTypes, Row.propTypes);  // Re-use existing Row and Col propType validations

// Can now be rendered as: <MyComponent end="sm" sm={8} value="my input value" onChange={...} />

Contributors

Roy Lee Helder Santana Matija Marohnić
Roy Lee Helder Santana Matija Marohnić

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].