npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-flex-lite

v7.0.1

Published

Flexbox components for React, as minimal as possible

Downloads

43

Readme

react-flex-lite NPM version Downloads

Information

Install

$ npm install react-flex-lite --save

Design

Heavily inspired by reflexbox and rebass.

This module aims to provide a very lightweight set of components on top of flexbox CSS and layout, and a higher order component to add this functionality to your own components. It does not handle breakpoints, media query listeners, or any other elements of responsive design. For that functionality, you should combine with a library like react-responsive.

Example Usage

Primary Components

import { Box, Flex } from 'react-flex-lite'

const Example = () => (
  <Flex column auto>
    <Flex shrink={0}>
      <Box>1</Box>
      <Box>2</Box>
      <Box>3</Box>
    </Flex>
    <Flex shrink={0}>
      <Box>1</Box>
      <Box>2</Box>
      <Box>3</Box>
    </Flex>
  </Flex>
)

Shorthand Components

For code clarity, VBox is a shorthand alias around <Flex column> and HBox is an alias for <Flex />

import { HBox, VBox } from 'react-flex-lite'

const Example = () => (
  <VBox auto>
    <Flex shrink={0}>
      <Box>1</Box>
      <Box>2</Box>
      <Box>3</Box>
    </HBox>
    <HBox shrink={0}>
      <Box>1</Box>
      <Box>2</Box>
      <Box>3</Box>
    </HBox>
  </VBox>
)

HOC

import { Layout } from 'react-flex-lite'

@Layout()
const Example = () => <div>Test</div>

Properties

  • m - Controls margin - number (for grid index, or pixels) or string (ie "100%")
  • mb - Controls margin-bottom - number (for grid index, or pixels) or string (ie "100%")
  • mt - Controls margin-top - number (for grid index, or pixels) or string (ie "100%")
  • mr - Controls margin-right - number (for grid index, or pixels) or string (ie "100%")
  • ml - Controls margin-left - number (for grid index, or pixels) or string (ie "100%")
  • mx - Controls margin-right and margin-left - number (for grid index, or pixels) or string (ie "100%")
  • my - Controls margin-top and margin-bottom - number (for grid index, or pixels) or string (ie "100%")
  • p - Controls padding - number (for grid index, or pixels) or string (ie "100%")
  • pb - Controls padding-bottom - number (for grid index, or pixels) or string (ie "100%")
  • pt - Controls padding-top - number (for grid index, or pixels) or string (ie "100%")
  • pr - Controls padding-righht - number (for grid index, or pixels) or string (ie "100%")
  • pl - Controls padding-left - number (for grid index, or pixels) or string (ie "100%")
  • px - Controls padding-right and padding-left - number (for grid index, or pixels) or string (ie "100%")
  • py - Controls padding-top and padding-bottom - number (for grid index, or pixels) or string (ie "100%")
  • h - Controls height - number (for pixels) or string (ie "100%")
  • w - Controls width - number (for pixels) or string (ie "100%")
  • flex - Sets display: flex - boolean
  • inline - Sets inline-flex - boolean
  • wrap - Sets flex-wrap - boolean
  • reverse - Sets row-reverse - boolean
  • column - Sets flex-direction: column - boolean
  • align - Sets align-items - One of 'normal', 'flex-start', 'flex-end', 'center', 'start', 'end', 'self-start', 'self-end', 'baseline', 'stretch', 'initial', 'inherit'
  • alignContent - Sets align-content - 'start', 'end', 'flex-start', 'flex-end', 'center', 'normal', 'baseline', 'space-between', 'space-around', 'space-evenly', 'stretch', 'initial', 'inherit'
  • alignSelf - Sets align-self - One of 'auto', 'normal', 'self-start', 'self-end', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline', 'initial', 'inherit'
  • justify - Sets justify-content - One of 'start', 'end', 'flex-start', 'flex-end', 'center', 'left', 'right', 'normal', 'space-between', 'space-around', 'space-evenly', 'baseline', 'initial', 'inherit'
  • order - Sets order - number
  • shrink - Sets flex-shrink - number, or boolean for 0 or 1
  • grow - Sets flex-grow - number, or boolean for 0 or 1
  • basis - Sets flex-basis - number
  • auto - Sets flex: 1 1 auto when true
  • hcenter - Sets properties needed to horizontally center contents
  • vcenter - Sets properties needed to vertically center contents
  • center - Sets properties needed to horizontally and vertically center contents

Providing your own grid

By default, this library comes with an 8px grid configuration:

{
  "space": [0, 8, 16, 32, 64]
}

To provide your own configuration, you can provide it via context:

import { LayoutContext } from 'react-flex-lite'

const config = {
  space: [0, 10, 20, 30, 40]
}

// in the root of your app
<LayoutContext.Provider value={config}>
  <YourApplication />
</LayoutContext.Provider>