All Projects → jxnblk → Reflexbox

jxnblk / Reflexbox

Moved to https://rebassjs.org

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Reflexbox

griding
🧱 lean grid & responsive for react
Stars: ✭ 18 (-98.69%)
Mutual labels:  grid, react-component, flexbox
Grid
This package has moved and renamed
Stars: ✭ 2,079 (+51.86%)
Mutual labels:  grid, css-in-js, flexbox
React Styled Flexboxgrid
Grid system based on styled-components and flexbox for React
Stars: ✭ 515 (-62.38%)
Mutual labels:  grid, flexbox
Flex Layout
Provides HTML UI layout for Angular applications; using Flexbox and a Responsive API
Stars: ✭ 5,705 (+316.73%)
Mutual labels:  grid, flexbox
Feather Flex
Ultralight flexbox based grid system.
Stars: ✭ 11 (-99.2%)
Mutual labels:  grid, flexbox
Griz
Grid library for React; Rescue the cat
Stars: ✭ 99 (-92.77%)
Mutual labels:  grid, flexbox
Pintsize
Customisable 💪 Flexbox grid system
Stars: ✭ 330 (-75.89%)
Mutual labels:  grid, flexbox
Ui Box
Blazing Fast React UI Primitive
Stars: ✭ 847 (-38.13%)
Mutual labels:  react-component, css-in-js
gridy
A Flexbox Grid System powered by SASS
Stars: ✭ 28 (-97.95%)
Mutual labels:  grid, flexbox
Lemon
🍋 Minimal and responsive CSS framework for fast building websites.
Stars: ✭ 51 (-96.27%)
Mutual labels:  grid, flexbox
Atgrid.css
CSS Grid System with attribute selectors
Stars: ✭ 37 (-97.3%)
Mutual labels:  grid, flexbox
React Stonecutter
Animated grid layout component for React
Stars: ✭ 1,089 (-20.45%)
Mutual labels:  grid, react-component
React Flexview
A powerful React component to abstract over flexbox and create any layout on any browser
Stars: ✭ 276 (-79.84%)
Mutual labels:  grid, flexbox
gutter-grid
A Sass flexbox based grid system that is able to replicate CSS grid-gap in IE11
Stars: ✭ 18 (-98.69%)
Mutual labels:  grid, flexbox
React Native Responsive Grid
Bringing the Web's Responsive Design to React Native
Stars: ✭ 369 (-73.05%)
Mutual labels:  grid, flexbox
gymnast
🤸 Configurable grid and layout engine for React
Stars: ✭ 35 (-97.44%)
Mutual labels:  grid, flexbox
React Flex Ready
A Flexbox grid ready, easy to implement and customize
Stars: ✭ 23 (-98.32%)
Mutual labels:  grid, flexbox
Vue Fraction Grid
Flexbox based responsive fraction grid system
Stars: ✭ 88 (-93.57%)
Mutual labels:  grid, flexbox
workshop-css-grid
Workshop made for freecodecamp meetup
Stars: ✭ 12 (-99.12%)
Mutual labels:  grid, flexbox
Katana
Katana is CSS Layout System made with Flexbox
Stars: ✭ 57 (-95.84%)
Mutual labels:  grid, flexbox

Reflexbox

Responsive React Flexbox Grid System

http://jxnblk.com/reflexbox

Build Status npm version

Features

  • Simple API for quickly controlling layout
  • Helps promote composability and separation of concerns
  • CSS-in-JS built in - no external dependencies
  • Only generates the CSS needed to render

Getting Started

npm install reflexbox
import React from 'react'
import { Flex, Box } from 'reflexbox'

class Component extends React.Component {
  render() {
    return (
      <Flex p={2} align='center'>
        <Box px={2} w={1/2}>Box A</Box>
        <Box px={2} w={1/2}>Box B</Box>
      </Flex>
    )
  }
}

Usage

// Fractional width
<Box w={1/2} />

// Pixel width
<Box w={128} />

// Responsive widths
<Box w={[ 1, 1/2, 1/4 ]} />

// Padding
<Box p={2} />

// Responsive padding
<Box p={[ 1, 2, 3 ]} />

// Margin
<Box m={2} />

// Responsive margin
<Box m={[ 1, 2, 3 ]} />

// top, right, bottom, left
<Box
  mt={1}
  mr={2}
  mb={3}
  ml={2}
/>

// x-axis
<Box mx={-2} />

// y-axis
<Box my={3} />

// align-items: center
<Flex align='center' />

// justify-content: space-between
<Flex justify='space-between' />

// Flex wrap
<Flex wrap />

// Flex direction column
<Flex column />

// Order
<Box order={2} />

// flex: 1 1 auto
<Box auto />

API

<Flex />

Component primitive with display: flex

<Box />

Primitive for controlling width, margin, padding and more.

Props

Both <Flex /> and <Box /> share the same props.

  • w (number|string) sets width, where numbers 0-1 are percentage values, larger numbers are pixel values, and strings are raw CSS values with units.
  • flex (boolean) sets display: flex
  • wrap (boolean) sets flex-wrap: wrap
  • column (boolean) sets flex-direction: column
  • auto (boolean) sets flex: 1 1 auto
  • order (number) sets order
  • align (string) sets align-items
  • justify (string) sets justify-content

Margin and Padding

Margin and padding props accept numbers 0-4 for values from the spacing scale [ 0, 8, 16, 32, 64 ]. Numbers greater than 4 will be used as pixel values. Negative values can be used for negative margins. Strings can be passed for other CSS values, e.g. mx='auto'

  • m (number|string) margin based on a scale from 0–4.
  • mx (number|string) x-axis margin based on a scale from 0–4.
  • my (number|string) y-axis margin based on a scale from 0–4.
  • mt (number|string) margin-top based on a scale from 0–4.
  • mb (number|string) margin-bottom based on a scale from 0–4.
  • ml (number|string) margin-left based on a scale from 0–4.
  • mr (number|string) margin-right based on a scale from 0–4.
  • p (number|string) padding based on a scale from 0–4.
  • px (number|string) x-axis padding based on a scale from 0–4.
  • py (number|string) y-axis padding based on a scale from 0–4.
  • pt (number|string) padding-top based on a scale from 0–4.
  • pb (number|string) padding-bottom based on a scale from 0–4.
  • pl (number|string) padding-left based on a scale from 0–4.
  • pr (number|string) padding-right based on a scale from 0–4.

Responsive Array Prop Values

All props accept arrays as values for mobile-first responsive styles.

// Set widths for different breakpoints, starting from smallest to largest
// This example will be 100% width below the smallest breakpoint,
// then 50% and 25% for the next two breakpoints respectively
<Box w={[ 1, 1/2, 1/4 ]} />

Null values can be passed to the array to skip a breakpoint.

<Box w={[ 1, null, 1/2 ]} />

Configuration

Values for the breakpoints and space scale can be configured with React Context.

Context can be set manually or with the <ReflexProvider /> component.

import React from 'react'
import { ReflexProvider, Flex, Box } from 'reflexbox'

const space = [ 0, 6, 12, 18, 24 ]
const breakpoints = [ 32, 48, 64 ]

class App extends React.Component {
  render () {
    return (
      <ReflexProvider
        space={space}
        breakpoints={breakpoints}>
        <Flex mx={-2}>
          <Box w={1/4} px={2}>Box</Box>
          <Box w={1/4} px={2}>Box</Box>
          <Box w={1/4} px={2}>Box</Box>
          <Box w={1/4} px={2}>Box</Box>
        </Flex>
      </ReflexProvider>
    )
  }
}

Higher Order Component

The core Reflexbox higher-order component can be used on any element that accepts className as a prop.

import React from 'react'
import { reflex } from 'reflexbox'
import MyInput from './MyInput'

const FlexInput = reflex(MyInput)

const App = () => (
  <div>
    <FlexInput
      w={1/2}
      mb={2}
      defaultValue='Flex Input'
    />
  </div>
)

Caveats

This currently DOES NOT work in Node.js server-side applications. If you need server-side support, see version ^2.2.0 or one of the related libraries below.


Related

MIT License

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